Back to SiteRouter class

Method buildComponentPreprocess

public void
buildComponentPreprocess
(mixed &$router, mixed &$uri)
Run the component preprocess method
Parameters
  • \Joomla\CMS\Router\SiteRouter & $router Router object
  • \Joomla\CMS\Uri\Uri & $uri URI object to process
Returns
  • void
Since
  • 4.0.0
Class: SiteRouter
Project: Joomla

Method buildComponentPreprocess - Source code

/**
 * Run the component preprocess method
 *
 * @param   SiteRouter  &$router  Router object
 * @param   Uri         &$uri     URI object to process
 *
 * @return  void
 *
 * @since   4.0.0
 */
public function buildComponentPreprocess(&$router, &$uri)
{
    // Get the query data
    $query = $uri->getQuery(true);
    if (!isset($query['option'])) {
        return;
    }
    $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
    $crouter = $this->getComponentRouter($component);
    $query = $crouter->preprocess($query);
    // Make sure any menu vars are used if no others are specified
    if (isset($query['Itemid']) && (\count($query) === 2 || \count($query) === 3 && isset($query['lang']))) {
        // Get the active menu item
        $item = $this->menu->getItem($query['Itemid']);
        $query = array_merge($item->query, $query);
    }
    $uri->setQuery($query);
}