Back to ComponentDispatcherFactory class

Method createDispatcher

public \Joomla\CMS\Dispatcher\DispatcherInterface
createDispatcher
(\Joomla\CMS\Application\CMSApplicationInterface $application, \Joomla\Input\Input $input = null)
Creates a dispatcher.
Parameters
  • \Joomla\CMS\Application\CMSApplicationInterface $application The application
  • \Joomla\Input\Input $input The input object, defaults to the one in the application
Returns
  • \Joomla\CMS\Dispatcher\DispatcherInterface
Since
  • 4.0.0

Method createDispatcher - Source code

/**
 * Creates a dispatcher.
 *
 * @param   CMSApplicationInterface  $application  The application
 * @param   Input                    $input        The input object, defaults to the one in the application
 *
 * @return  DispatcherInterface
 *
 * @since   4.0.0
 */
public function createDispatcher(CMSApplicationInterface $application, Input $input = null) : DispatcherInterface
{
    $name = ucfirst($application->getName());
    $className = '\\' . trim($this->namespace, '\\') . '\\' . $name . '\\Dispatcher\\Dispatcher';
    if (!class_exists($className)) {
        if ($application->isClient('api')) {
            $className = ApiDispatcher::class;
        } else {
            $className = ComponentDispatcher::class;
        }
    }
    return new $className($application, $input ?: $application->input, $this->mvcFactory);
}