[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_fields
   6   *
   7   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Categories\CategoryFactoryInterface;
  14  use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
  15  use Joomla\CMS\Extension\ComponentInterface;
  16  use Joomla\CMS\Extension\Service\Provider\CategoryFactory;
  17  use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
  18  use Joomla\CMS\Extension\Service\Provider\MVCFactory;
  19  use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
  20  use Joomla\Component\Fields\Administrator\Extension\FieldsComponent;
  21  use Joomla\DI\Container;
  22  use Joomla\DI\ServiceProviderInterface;
  23  
  24  /**
  25   * The fields service provider.
  26   *
  27   * @since  4.0.0
  28   */
  29  return new class implements ServiceProviderInterface
  30  {
  31      /**
  32       * Registers the service provider with a DI container.
  33       *
  34       * @param   Container  $container  The DI container.
  35       *
  36       * @return  void
  37       *
  38       * @since   4.0.0
  39       */
  40      public function register(Container $container)
  41      {
  42          $container->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Fields'));
  43          $container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Fields'));
  44          $container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Fields'));
  45  
  46          $container->set(
  47              ComponentInterface::class,
  48              function (Container $container) {
  49                  $component = new FieldsComponent($container->get(ComponentDispatcherFactoryInterface::class));
  50  
  51                  $component->setMVCFactory($container->get(MVCFactoryInterface::class));
  52                  $component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
  53  
  54                  return $component;
  55              }
  56          );
  57      }
  58  };


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