[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_menus
   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\Association\AssociationExtensionInterface;
  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\Menus\Administrator\Extension\MenusComponent;
  21  use Joomla\Component\Menus\Administrator\Helper\AssociationsHelper;
  22  use Joomla\DI\Container;
  23  use Joomla\DI\ServiceProviderInterface;
  24  
  25  /**
  26   * The menus service provider.
  27   *
  28   * @since  4.0.0
  29   */
  30  return new class implements ServiceProviderInterface
  31  {
  32      /**
  33       * Registers the service provider with a DI container.
  34       *
  35       * @param   Container  $container  The DI container.
  36       *
  37       * @return  void
  38       *
  39       * @since   4.0.0
  40       */
  41      public function register(Container $container)
  42      {
  43          $container->set(AssociationExtensionInterface::class, new AssociationsHelper());
  44  
  45          $container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Menus'));
  46          $container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Menus'));
  47  
  48          $container->set(
  49              ComponentInterface::class,
  50              function (Container $container) {
  51                  $component = new MenusComponent($container->get(ComponentDispatcherFactoryInterface::class));
  52  
  53                  $component->setRegistry($container->get(Registry::class));
  54                  $component->setMVCFactory($container->get(MVCFactoryInterface::class));
  55                  $component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
  56  
  57                  return $component;
  58              }
  59          );
  60      }
  61  };


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