[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Extension/Service/Provider/ -> ModuleDispatcherFactory.php (source)

   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\Dispatcher\ModuleDispatcherFactoryInterface;
  13  use Joomla\DI\Container;
  14  use Joomla\DI\ServiceProviderInterface;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('JPATH_PLATFORM') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Service provider for the service dispatcher factory.
  22   *
  23   * @since  4.0.0
  24   */
  25  class ModuleDispatcherFactory implements ServiceProviderInterface
  26  {
  27      /**
  28       * The module namespace
  29       *
  30       * @var  string
  31       *
  32       * @since   4.0.0
  33       */
  34      private $namespace;
  35  
  36      /**
  37       * ComponentDispatcherFactory constructor.
  38       *
  39       * @param   string  $namespace  The namespace
  40       *
  41       * @since   4.0.0
  42       */
  43      public function __construct(string $namespace)
  44      {
  45          $this->namespace = $namespace;
  46      }
  47  
  48      /**
  49       * Registers the service provider with a DI container.
  50       *
  51       * @param   Container  $container  The DI container.
  52       *
  53       * @return  void
  54       *
  55       * @since   4.0.0
  56       */
  57      public function register(Container $container)
  58      {
  59          $container->set(
  60              ModuleDispatcherFactoryInterface::class,
  61              function (Container $container) {
  62                  return new \Joomla\CMS\Dispatcher\ModuleDispatcherFactory($this->namespace);
  63              }
  64          );
  65      }
  66  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer