[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/installation/src/Service/Provider/ -> Application.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Installation
   5   * @subpackage  Service
   6   *
   7   * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\CMS\Installation\Service\Provider;
  12  
  13  use Joomla\CMS\Error\Renderer\JsonRenderer;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\Installation\Application\InstallationApplication;
  16  use Joomla\DI\Container;
  17  use Joomla\DI\ServiceProviderInterface;
  18  use Psr\Log\LoggerInterface;
  19  
  20  // phpcs:disable PSR1.Files.SideEffects
  21  \defined('JPATH_PLATFORM') or die;
  22  // phpcs:enable PSR1.Files.SideEffects
  23  
  24  /**
  25   * Application service provider
  26   *
  27   * @since  4.0.0
  28   */
  29  class Application implements ServiceProviderInterface
  30  {
  31      /**
  32       * Registers the service provider with a DI container.
  33       *
  34       * @param   Container  $container  The DI container.
  35       *
  36       * @return  void
  37       *
  38       * @since   4.0.0
  39       */
  40      public function register(Container $container)
  41      {
  42          $container->share(
  43              InstallationApplication::class,
  44              function (Container $container) {
  45                  $app = new InstallationApplication(null, $container->get('config'), null, $container);
  46  
  47                  // The session service provider needs Factory::$application, set it if still null
  48                  if (Factory::$application === null) {
  49                      Factory::$application = $app;
  50                  }
  51  
  52                  $app->setDispatcher($container->get('Joomla\Event\DispatcherInterface'));
  53                  $app->setLogger($container->get(LoggerInterface::class));
  54                  $app->setSession($container->get('Joomla\Session\SessionInterface'));
  55  
  56                  return $app;
  57              },
  58              true
  59          );
  60  
  61          // Inject a custom JSON error renderer
  62          $container->share(
  63              JsonRenderer::class,
  64              function (Container $container) {
  65                  return new \Joomla\CMS\Installation\Error\Renderer\JsonRenderer();
  66              }
  67          );
  68      }
  69  }


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