- md5
- 2c3fd48300eaed87a050f10229c6e34e
- sha1
- 45255762444dfc146da854c80921e880fc9e40e5
- sha256
- ed8cc9d6cc8f6ee1cdac5fe960df7eacaef6f3d58486cc5c5c1d557f79cf7faa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
<?php
/**
* @package Joomla.Libraries
* @subpackage Service
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Service\Provider;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Application\AdministratorApplication;
use Joomla\CMS\Application\ApiApplication;
use Joomla\CMS\Application\ConsoleApplication;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Console\SessionGcCommand;
use Joomla\CMS\Console\SessionMetadataGcCommand;
use Joomla\CMS\Factory;
use Joomla\Console\Application as BaseConsoleApplication;
use Joomla\Console\Loader\ContainerLoader;
use Joomla\Console\Loader\LoaderInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Session\SessionInterface;
use Psr\Log\LoggerInterface;
/**
* Application service provider
*
* @since 4.0
*/
class Application implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0
*/
public function register(Container $container)
{
$container->alias(AdministratorApplication::class, 'JApplicationAdministrator')
->share(
'JApplicationAdministrator',
function (Container $container)
{
$app = new AdministratorApplication(null, $container->get('config'), null, $container);
// The session service provider needs Factory::$application, set it if still null
if (Factory::$application === null)
{
Factory::$application = $app;
}
$app->setDispatcher($container->get(DispatcherInterface::class));
$app->setLogger($container->get(LoggerInterface::class));
$app->setSession($container->get(SessionInterface::class));
return $app;
},
true
);
$container->alias(SiteApplication::class, 'JApplicationSite')
->share(
'JApplicationSite',
function (Container $container)
{
$app = new SiteApplication(null, $container->get('config'), null, $container);
// The session service provider needs Factory::$application, set it if still null
if (Factory::$application === null)
{
Factory::$application = $app;
}
$app->setDispatcher($container->get(DispatcherInterface::class));
$app->setLogger($container->get(LoggerInterface::class));
$app->setSession($container->get(SessionInterface::class));
return $app;
},
true
);
$container->alias(ConsoleApplication::class, BaseConsoleApplication::class)
->share(
BaseConsoleApplication::class,
function (Container $container)
{
$dispatcher = $container->get(DispatcherInterface::class);
$app = new ConsoleApplication(null, null, $container->get('config'), $dispatcher, $container);
// The session service provider needs Factory::$application, set it if still null
if (Factory::$application === null)
{
Factory::$application = $app;
}
$app->setCommandLoader($container->get(LoaderInterface::class));
$app->setLogger($container->get(LoggerInterface::class));
$app->setSession($container->get(SessionInterface::class));
return $app;
},
true
);
$container->alias(ContainerLoader::class, LoaderInterface::class)
->share(
LoaderInterface::class,
function (Container $container)
{
$mapping = [
SessionGcCommand::getDefaultName() => SessionGcCommand::class,
SessionMetadataGcCommand::getDefaultName() => SessionMetadataGcCommand::class,
];
return new ContainerLoader($container, $mapping);
},
true
);
$container->alias(ApiApplication::class, 'JApplicationApi')
->share(
'JApplicationApi',
function (Container $container) {
$app = new ApiApplication(null, null, null, $container);
// The session service provider needs JFactory::$application, set it if still null
if (Factory::$application === null)
{
Factory::$application = $app;
}
$app->setDispatcher($container->get('Joomla\Event\DispatcherInterface'));
$app->setLogger($container->get(LoggerInterface::class));
$app->setSession($container->get('Joomla\Session\SessionInterface'));
return $app;
},
true
);
}
}
No other release has this exact content. See every version of this file.