[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2017 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\Service\Provider;
  11  
  12  use Joomla\CMS\Cache\CacheControllerFactoryInterface;
  13  use Joomla\CMS\Menu\MenuFactory;
  14  use Joomla\CMS\Menu\MenuFactoryInterface;
  15  use Joomla\Database\DatabaseInterface;
  16  use Joomla\DI\Container;
  17  use Joomla\DI\ServiceProviderInterface;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('JPATH_PLATFORM') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * Service provider for the application's menu dependency
  25   *
  26   * @since  4.0.0
  27   */
  28  class Menu implements ServiceProviderInterface
  29  {
  30      /**
  31       * Registers the service provider with a DI container.
  32       *
  33       * @param   Container  $container  The DI container.
  34       *
  35       * @return  void
  36       *
  37       * @since   4.0.0
  38       */
  39      public function register(Container $container)
  40      {
  41          $container->alias('menu.factory', MenuFactoryInterface::class)
  42              ->alias(MenuFactory::class, MenuFactoryInterface::class)
  43              ->share(
  44                  MenuFactoryInterface::class,
  45                  function (Container $container) {
  46                      $factory = new MenuFactory();
  47                      $factory->setCacheControllerFactory($container->get(CacheControllerFactoryInterface::class));
  48                      $factory->setDatabase($container->get(DatabaseInterface::class));
  49  
  50                      return $factory;
  51                  },
  52                  true
  53              );
  54      }
  55  }


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