[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/system/cache/services/ -> provider.php (source)

   1  <?php
   2  /**
   3   * @package     Joomla.Plugin
   4   * @subpackage  System.cache
   5   *
   6   * @copyright   (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  defined('_JEXEC') or die;
  11  
  12  use Joomla\CMS\Cache\CacheControllerFactoryInterface;
  13  use Joomla\CMS\Extension\PluginInterface;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Plugin\PluginHelper;
  16  use Joomla\CMS\Profiler\Profiler;
  17  use Joomla\CMS\Router\SiteRouter;
  18  use Joomla\DI\Container;
  19  use Joomla\DI\ServiceProviderInterface;
  20  use Joomla\Event\DispatcherInterface;
  21  use Joomla\Plugin\System\Cache\Extension\Cache;
  22  
  23  return new class implements ServiceProviderInterface
  24  {
  25      /**
  26       * Registers the service provider with a DI container.
  27       *
  28       * @param   Container  $container  The DI container.
  29       *
  30       * @return  void
  31       * @since   4.2.0
  32       */
  33  	public function register(Container $container)
  34      {
  35          $container->set(
  36              PluginInterface::class,
  37              function (Container $container)
  38              {
  39                  $plugin                 = PluginHelper::getPlugin('system', 'cache');
  40                  $dispatcher             = $container->get(DispatcherInterface::class);
  41                  $documentFactory        = $container->get('document.factory');
  42                  $cacheControllerFactory = $container->get(CacheControllerFactoryInterface::class);
  43                  $profiler               = (defined('JDEBUG') && JDEBUG) ? Profiler::getInstance('Application') : null;
  44                  $router                 = $container->has(SiteRouter::class) ? $container->get(SiteRouter::class) : null;
  45  
  46                  $plugin = new Cache($dispatcher, (array) $plugin, $documentFactory, $cacheControllerFactory, $profiler, $router);
  47                  $plugin->setApplication(Factory::getApplication());
  48  
  49                  return $plugin;
  50              }
  51          );
  52      }
  53  };


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