[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_newsfeeds
   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\Categories\CategoryFactoryInterface;
  15  use Joomla\CMS\Component\Router\RouterFactoryInterface;
  16  use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
  17  use Joomla\CMS\Extension\ComponentInterface;
  18  use Joomla\CMS\Extension\Service\Provider\CategoryFactory;
  19  use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
  20  use Joomla\CMS\Extension\Service\Provider\MVCFactory;
  21  use Joomla\CMS\Extension\Service\Provider\RouterFactory;
  22  use Joomla\CMS\HTML\Registry;
  23  use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
  24  use Joomla\Component\Newsfeeds\Administrator\Extension\NewsfeedsComponent;
  25  use Joomla\Component\Newsfeeds\Administrator\Helper\AssociationsHelper;
  26  use Joomla\DI\Container;
  27  use Joomla\DI\ServiceProviderInterface;
  28  
  29  /**
  30   * The newsfeed service provider.
  31   *
  32   * @since  4.0.0
  33   */
  34  return new class implements ServiceProviderInterface
  35  {
  36      /**
  37       * Registers the service provider with a DI container.
  38       *
  39       * @param   Container  $container  The DI container.
  40       *
  41       * @return  void
  42       *
  43       * @since   4.0.0
  44       */
  45      public function register(Container $container)
  46      {
  47          $container->set(AssociationExtensionInterface::class, new AssociationsHelper());
  48  
  49          $container->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Newsfeeds'));
  50          $container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Newsfeeds'));
  51          $container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Newsfeeds'));
  52          $container->registerServiceProvider(new RouterFactory('\\Joomla\\Component\\Newsfeeds'));
  53  
  54          $container->set(
  55              ComponentInterface::class,
  56              function (Container $container) {
  57                  $component = new NewsfeedsComponent($container->get(ComponentDispatcherFactoryInterface::class));
  58  
  59                  $component->setRegistry($container->get(Registry::class));
  60                  $component->setMVCFactory($container->get(MVCFactoryInterface::class));
  61                  $component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
  62                  $component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
  63                  $component->setRouterFactory($container->get(RouterFactoryInterface::class));
  64  
  65                  return $component;
  66              }
  67          );
  68      }
  69  };


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