CoreFiles by mySites.guru
Application.php88 lines, 2,921 bytes, from Joomla_6.2.0-Stable-Full_Package.zip
Raw History Compare with 6.1.4
md5
a3441a20df87100c869aa2f0d2d24264
sha1
39e29308330f23ad8f5d4a5927e95905b8650bcc
sha256
533a90c2f8a2427dd9ad470ece6155c71df5643c5ed55c819c35d4bfe82d2754
<?php

/**
 * @package     Joomla.Installation
 * @subpackage  Service
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Installation\Service\Provider;

use Joomla\CMS\Error\Renderer\JsonRenderer;
use Joomla\CMS\Installation\Application\CliInstallationApplication;
use Joomla\CMS\Installation\Application\InstallationApplication;
use Joomla\CMS\Language\LanguageFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Event\Priority;
use Joomla\Input\Input as CMSInput;
use Joomla\Session\SessionEvents;
use Joomla\Session\SessionInterface;
use Psr\Log\LoggerInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Application service provider
 *
 * @since  4.0.0
 */
class Application implements ServiceProviderInterface
{
    /**
     * Registers the service provider with a DI container.
     *
     * @param   Container  $container  The DI container.
     *
     * @return  void
     *
     * @since   4.0.0
     */
    public function register(Container $container)
    {
        $container->share(
            InstallationApplication::class,
            function (Container $container) {
                $app = new InstallationApplication($container->get(CMSInput::class), $container->get('config'), null, $container);
                $app->setDispatcher($container->get(DispatcherInterface::class));
                $app->setLogger($container->get(LoggerInterface::class));
                $app->setSession($container->get(SessionInterface::class));

                // Ensure that session purging is configured now we have a dispatcher
                $app->getDispatcher()->addListener(SessionEvents::START, [$app, 'afterSessionStart'], Priority::HIGH);

                return $app;
            },
            true
        );

        $container->share(
            CliInstallationApplication::class,
            function (Container $container) {
                $lang = $container->get(LanguageFactoryInterface::class)->createLanguage('en-GB', false);

                $app = new CliInstallationApplication(null, null, $container->get('config'), $lang);

                $app->setDispatcher($container->get(DispatcherInterface::class));
                $app->setLogger($container->get(LoggerInterface::class));
                $app->setSession($container->get(SessionInterface::class));

                return $app;
            },
            true
        );

        // Inject a custom JSON error renderer
        $container->share(
            JsonRenderer::class,
            function (Container $container) {
                return new \Joomla\CMS\Installation\Error\Renderer\JsonRenderer();
            }
        );
    }
}

The same content is in 5 releases, Joomla 6.2.0-beta3 to 6.2.1-rc1. See them all, or every version of this file.