[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2018 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\Application\AdministratorApplication; 13 use Joomla\CMS\Application\ApiApplication; 14 use Joomla\CMS\Application\ConsoleApplication; 15 use Joomla\CMS\Application\SiteApplication; 16 use Joomla\CMS\Cache\CacheControllerFactoryInterface; 17 use Joomla\CMS\Console\CheckJoomlaUpdatesCommand; 18 use Joomla\CMS\Console\ExtensionDiscoverCommand; 19 use Joomla\CMS\Console\ExtensionDiscoverInstallCommand; 20 use Joomla\CMS\Console\ExtensionDiscoverListCommand; 21 use Joomla\CMS\Console\ExtensionInstallCommand; 22 use Joomla\CMS\Console\ExtensionRemoveCommand; 23 use Joomla\CMS\Console\ExtensionsListCommand; 24 use Joomla\CMS\Console\FinderIndexCommand; 25 use Joomla\CMS\Console\GetConfigurationCommand; 26 use Joomla\CMS\Console\Loader\WritableContainerLoader; 27 use Joomla\CMS\Console\Loader\WritableLoaderInterface; 28 use Joomla\CMS\Console\SessionGcCommand; 29 use Joomla\CMS\Console\SessionMetadataGcCommand; 30 use Joomla\CMS\Console\SetConfigurationCommand; 31 use Joomla\CMS\Console\SiteDownCommand; 32 use Joomla\CMS\Console\SiteUpCommand; 33 use Joomla\CMS\Console\TasksListCommand; 34 use Joomla\CMS\Console\TasksRunCommand; 35 use Joomla\CMS\Console\TasksStateCommand; 36 use Joomla\CMS\Console\UpdateCoreCommand; 37 use Joomla\CMS\Factory; 38 use Joomla\CMS\Language\LanguageFactoryInterface; 39 use Joomla\CMS\Menu\MenuFactoryInterface; 40 use Joomla\CMS\User\UserFactoryInterface; 41 use Joomla\Console\Application as BaseConsoleApplication; 42 use Joomla\Console\Loader\LoaderInterface; 43 use Joomla\Database\Command\ExportCommand; 44 use Joomla\Database\Command\ImportCommand; 45 use Joomla\Database\DatabaseInterface; 46 use Joomla\DI\Container; 47 use Joomla\DI\ServiceProviderInterface; 48 use Joomla\Event\DispatcherInterface; 49 use Joomla\Session\SessionInterface; 50 use Psr\Log\LoggerInterface; 51 52 // phpcs:disable PSR1.Files.SideEffects 53 \defined('JPATH_PLATFORM') or die; 54 // phpcs:enable PSR1.Files.SideEffects 55 56 /** 57 * Application service provider 58 * 59 * @since 4.0.0 60 */ 61 class Application implements ServiceProviderInterface 62 { 63 /** 64 * Registers the service provider with a DI container. 65 * 66 * @param Container $container The DI container. 67 * 68 * @return void 69 * 70 * @since 4.0.0 71 */ 72 public function register(Container $container) 73 { 74 $container->alias(AdministratorApplication::class, 'JApplicationAdministrator') 75 ->share( 76 'JApplicationAdministrator', 77 function (Container $container) { 78 $app = new AdministratorApplication(null, $container->get('config'), null, $container); 79 80 // The session service provider needs Factory::$application, set it if still null 81 if (Factory::$application === null) { 82 Factory::$application = $app; 83 } 84 85 $app->setDispatcher($container->get(DispatcherInterface::class)); 86 $app->setLogger($container->get(LoggerInterface::class)); 87 $app->setSession($container->get(SessionInterface::class)); 88 $app->setUserFactory($container->get(UserFactoryInterface::class)); 89 $app->setMenuFactory($container->get(MenuFactoryInterface::class)); 90 91 return $app; 92 }, 93 true 94 ); 95 96 $container->alias(SiteApplication::class, 'JApplicationSite') 97 ->share( 98 'JApplicationSite', 99 function (Container $container) { 100 $app = new SiteApplication(null, $container->get('config'), null, $container); 101 102 // The session service provider needs Factory::$application, set it if still null 103 if (Factory::$application === null) { 104 Factory::$application = $app; 105 } 106 107 $app->setDispatcher($container->get(DispatcherInterface::class)); 108 $app->setLogger($container->get(LoggerInterface::class)); 109 $app->setSession($container->get(SessionInterface::class)); 110 $app->setUserFactory($container->get(UserFactoryInterface::class)); 111 $app->setCacheControllerFactory($container->get(CacheControllerFactoryInterface::class)); 112 $app->setMenuFactory($container->get(MenuFactoryInterface::class)); 113 114 return $app; 115 }, 116 true 117 ); 118 119 $container->alias(ConsoleApplication::class, BaseConsoleApplication::class) 120 ->share( 121 BaseConsoleApplication::class, 122 function (Container $container) { 123 $dispatcher = $container->get(DispatcherInterface::class); 124 125 // Console uses the default system language 126 $config = $container->get('config'); 127 $locale = $config->get('language'); 128 $debug = $config->get('debug_lang'); 129 130 $lang = $container->get(LanguageFactoryInterface::class)->createLanguage($locale, $debug); 131 132 $app = new ConsoleApplication($config, $dispatcher, $container, $lang); 133 134 // The session service provider needs Factory::$application, set it if still null 135 if (Factory::$application === null) { 136 Factory::$application = $app; 137 } 138 139 $app->setCommandLoader($container->get(LoaderInterface::class)); 140 $app->setLogger($container->get(LoggerInterface::class)); 141 $app->setSession($container->get(SessionInterface::class)); 142 $app->setUserFactory($container->get(UserFactoryInterface::class)); 143 $app->setDatabase($container->get(DatabaseInterface::class)); 144 145 return $app; 146 }, 147 true 148 ); 149 150 $container->alias(WritableContainerLoader::class, LoaderInterface::class) 151 ->alias(WritableLoaderInterface::class, LoaderInterface::class) 152 ->share( 153 LoaderInterface::class, 154 function (Container $container) { 155 $mapping = [ 156 SessionGcCommand::getDefaultName() => SessionGcCommand::class, 157 SessionMetadataGcCommand::getDefaultName() => SessionMetadataGcCommand::class, 158 ExportCommand::getDefaultName() => ExportCommand::class, 159 ImportCommand::getDefaultName() => ImportCommand::class, 160 SiteDownCommand::getDefaultName() => SiteDownCommand::class, 161 SiteUpCommand::getDefaultName() => SiteUpCommand::class, 162 SetConfigurationCommand::getDefaultName() => SetConfigurationCommand::class, 163 GetConfigurationCommand::getDefaultName() => GetConfigurationCommand::class, 164 ExtensionsListCommand::getDefaultName() => ExtensionsListCommand::class, 165 CheckJoomlaUpdatesCommand::getDefaultName() => CheckJoomlaUpdatesCommand::class, 166 ExtensionRemoveCommand::getDefaultName() => ExtensionRemoveCommand::class, 167 ExtensionInstallCommand::getDefaultName() => ExtensionInstallCommand::class, 168 ExtensionDiscoverCommand::getDefaultName() => ExtensionDiscoverCommand::class, 169 ExtensionDiscoverInstallCommand::getDefaultName() => ExtensionDiscoverInstallCommand::class, 170 ExtensionDiscoverListCommand::getDefaultName() => ExtensionDiscoverListCommand::class, 171 UpdateCoreCommand::getDefaultName() => UpdateCoreCommand::class, 172 FinderIndexCommand::getDefaultName() => FinderIndexCommand::class, 173 TasksListCommand::getDefaultName() => TasksListCommand::class, 174 TasksRunCommand::getDefaultName() => TasksRunCommand::class, 175 TasksStateCommand::getDefaultName() => TasksStateCommand::class, 176 ]; 177 178 return new WritableContainerLoader($container, $mapping); 179 }, 180 true 181 ); 182 183 $container->alias(ApiApplication::class, 'JApplicationApi') 184 ->share( 185 'JApplicationApi', 186 function (Container $container) { 187 $app = new ApiApplication(null, $container->get('config'), null, $container); 188 189 // The session service provider needs Factory::$application, set it if still null 190 if (Factory::$application === null) { 191 Factory::$application = $app; 192 } 193 194 $app->setDispatcher($container->get('Joomla\Event\DispatcherInterface')); 195 $app->setLogger($container->get(LoggerInterface::class)); 196 $app->setSession($container->get('Joomla\Session\SessionInterface')); 197 $app->setMenuFactory($container->get(MenuFactoryInterface::class)); 198 199 return $app; 200 }, 201 true 202 ); 203 } 204 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |