[ 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.txt 8 */ 9 10 namespace Joomla\CMS\Extension\Service\Provider; 11 12 use Joomla\CMS\Categories\CategoryFactoryInterface; 13 use Joomla\CMS\Component\Router\RouterFactoryInterface; 14 use Joomla\Database\DatabaseInterface; 15 use Joomla\DI\Container; 16 use Joomla\DI\ServiceProviderInterface; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('JPATH_PLATFORM') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Service provider for the service router factory. 24 * 25 * @since 4.0.0 26 */ 27 class RouterFactory implements ServiceProviderInterface 28 { 29 /** 30 * The module namespace 31 * 32 * @var string 33 * 34 * @since 4.0.0 35 */ 36 private $namespace; 37 38 /** 39 * DispatcherFactory constructor. 40 * 41 * @param string $namespace The namespace 42 * 43 * @since 4.0.0 44 */ 45 public function __construct(string $namespace) 46 { 47 $this->namespace = $namespace; 48 } 49 50 /** 51 * Registers the service provider with a DI container. 52 * 53 * @param Container $container The DI container. 54 * 55 * @return void 56 * 57 * @since 4.0.0 58 */ 59 public function register(Container $container) 60 { 61 $container->set( 62 RouterFactoryInterface::class, 63 function (Container $container) { 64 $categoryFactory = null; 65 66 if ($container->has(CategoryFactoryInterface::class)) { 67 $categoryFactory = $container->get(CategoryFactoryInterface::class); 68 } 69 70 return new \Joomla\CMS\Component\Router\RouterFactory( 71 $this->namespace, 72 $categoryFactory, 73 $container->get(DatabaseInterface::class) 74 ); 75 } 76 ); 77 } 78 }
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 |