Back to SiteApplication class

Method dispatch

public void
dispatch
(mixed $component = null)
Dispatch the application
Parameters
  • string $component The component which is being rendered.
Returns
  • void
Since
  • 3.2

Method dispatch - Source code

/**
 * Dispatch the application
 *
 * @param   string  $component  The component which is being rendered.
 *
 * @return  void
 *
 * @since   3.2
 */
public function dispatch($component = null)
{
    // Get the component if not set.
    if (!$component) {
        $component = $this->input->getCmd('option', null);
    }
    // Load the document to the API
    $this->loadDocument();
    // Set up the params
    $document = $this->getDocument();
    $params = $this->getParams();
    // Register the document object with Factory
    Factory::$document = $document;
    switch ($document->getType()) {
        case 'html':
            // Set up the language
            LanguageHelper::getLanguages('lang_code');
            // Set metadata
            $document->setMetaData('rights', $this->get('MetaRights'));
            // Get the template
            $template = $this->getTemplate(true);
            // Store the template and its params to the config
            $this->set('theme', $template->template);
            $this->set('themeParams', $template->params);
            // Add Asset registry files
            $wr = $document->getWebAssetManager()->getRegistry();
            if ($component) {
                $wr->addExtensionRegistryFile($component);
            }
            if ($template->parent) {
                $wr->addTemplateRegistryFile($template->parent, $this->getClientId());
            }
            $wr->addTemplateRegistryFile($template->template, $this->getClientId());
            break;
        case 'feed':
            $document->setBase(htmlspecialchars(Uri::current()));
            break;
    }
    $document->setTitle($params->get('page_title'));
    $document->setDescription($params->get('page_description'));
    // Add version number or not based on global configuration
    if ($this->get('MetaVersion', 0)) {
        $document->setGenerator('Joomla! - Open Source Content Management - Version ' . JVERSION);
    } else {
        $document->setGenerator('Joomla! - Open Source Content Management');
    }
    $contents = ComponentHelper::renderComponent($component);
    $document->setBuffer($contents, 'component');
    // Trigger the onAfterDispatch event.
    PluginHelper::importPlugin('system');
    $this->triggerEvent('onAfterDispatch');
}