[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

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


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