[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_scheduler/services/ -> provider.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_scheduler
   6   *
   7   * @copyright   (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  // Restrict direct access
  12  defined('_JEXEC') or die;
  13  
  14  use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
  15  use Joomla\CMS\Extension\ComponentInterface;
  16  use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
  17  use Joomla\CMS\Extension\Service\Provider\MVCFactory;
  18  use Joomla\CMS\HTML\Registry;
  19  use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
  20  use Joomla\Component\Scheduler\Administrator\Extension\SchedulerComponent;
  21  use Joomla\DI\Container;
  22  use Joomla\DI\ServiceProviderInterface;
  23  
  24  /**
  25   * The com_scheduler service provider.
  26   * Returns an instance of the Component's Service Provider Interface
  27   * used to register the components initializers into a DI container
  28   * created by the application.
  29   *
  30   * @since  4.1.0
  31   */
  32  return new class implements ServiceProviderInterface
  33  {
  34      /**
  35       * Registers the service provider with a DI container.
  36       *
  37       * @param   Container $container The DI container.
  38       *
  39       * @return void
  40       *
  41       * @since  4.1.0
  42       */
  43      public function register(Container $container)
  44      {
  45          /**
  46           * Register the MVCFactory and ComponentDispatcherFactory providers to map
  47           * 'MVCFactoryInterface' and 'ComponentDispatcherFactoryInterface' to their
  48           * initializers and register them with the component's DI container.
  49           */
  50          $container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Scheduler'));
  51          $container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Scheduler'));
  52  
  53          $container->set(
  54              ComponentInterface::class,
  55              function (Container $container) {
  56                  $component = new SchedulerComponent($container->get(ComponentDispatcherFactoryInterface::class));
  57  
  58                  $component->setRegistry($container->get(Registry::class));
  59                  $component->setMVCFactory($container->get(MVCFactoryInterface::class));
  60  
  61                  return $component;
  62              }
  63          );
  64      }
  65  };


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