[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE 8 */ 9 10 namespace Joomla\CMS\Dispatcher; 11 12 use Joomla\CMS\Application\CMSApplicationInterface; 13 use Joomla\CMS\MVC\Factory\MVCFactoryInterface; 14 use Joomla\Input\Input; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('_JEXEC') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Namespace based implementation of the ComponentDispatcherFactoryInterface 22 * 23 * @since 4.0.0 24 */ 25 class ComponentDispatcherFactory implements ComponentDispatcherFactoryInterface 26 { 27 /** 28 * The extension namespace 29 * 30 * @var string 31 * 32 * @since 4.0.0 33 */ 34 protected $namespace; 35 36 /** 37 * The MVC factory 38 * 39 * @var MVCFactoryInterface 40 * 41 * @since 4.0.0 42 */ 43 private $mvcFactory; 44 45 /** 46 * ComponentDispatcherFactory constructor. 47 * 48 * @param string $namespace The namespace 49 * @param MVCFactoryInterface $mvcFactory The MVC factory 50 * 51 * @since 4.0.0 52 */ 53 public function __construct(string $namespace, MVCFactoryInterface $mvcFactory) 54 { 55 $this->namespace = $namespace; 56 $this->mvcFactory = $mvcFactory; 57 } 58 59 /** 60 * Creates a dispatcher. 61 * 62 * @param CMSApplicationInterface $application The application 63 * @param Input $input The input object, defaults to the one in the application 64 * 65 * @return DispatcherInterface 66 * 67 * @since 4.0.0 68 */ 69 public function createDispatcher(CMSApplicationInterface $application, Input $input = null): DispatcherInterface 70 { 71 $name = ucfirst($application->getName()); 72 73 $className = '\\' . trim($this->namespace, '\\') . '\\' . $name . '\\Dispatcher\\Dispatcher'; 74 75 if (!class_exists($className)) { 76 if ($application->isClient('api')) { 77 $className = ApiDispatcher::class; 78 } else { 79 $className = ComponentDispatcher::class; 80 } 81 } 82 83 return new $className($application, $input ?: $application->input, $this->mvcFactory); 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |