mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-30 17:13:41 +00:00
Remove arguments of Factory::getApplication as they are misleading (#18898)
This commit is contained in:
parent
2794f611c4
commit
58e19566a1
|
@ -29,7 +29,10 @@ require_once JPATH_BASE . '/includes/framework.php';
|
|||
JDEBUG ? JProfiler::getInstance('Application')->setStart($startTime, $startMem)->mark('afterLoad') : null;
|
||||
|
||||
// Instantiate the application.
|
||||
$app = JFactory::getApplication('administrator');
|
||||
$app = \Joomla\CMS\Factory::getContainer()->get(\Joomla\CMS\Application\AdministratorApplication::class);
|
||||
|
||||
// Set the application as global app
|
||||
\Joomla\CMS\Factory::$application = $app;
|
||||
|
||||
// Execute the application.
|
||||
$app->execute();
|
||||
|
|
|
@ -28,8 +28,11 @@ require_once JPATH_BASE . '/includes/framework.php';
|
|||
// Set profiler start time and memory usage and mark afterLoad in the profiler.
|
||||
JDEBUG ? JProfiler::getInstance('Application')->setStart($startTime, $startMem)->mark('afterLoad') : null;
|
||||
|
||||
// Instantiate the application.
|
||||
$app = JFactory::getApplication('site');
|
||||
// Get the application.
|
||||
$app = \Joomla\CMS\Factory::getContainer()->get(\Joomla\CMS\Application\SiteApplication::class);
|
||||
|
||||
// Set the application as global app
|
||||
\Joomla\CMS\Factory::$application = $app;
|
||||
|
||||
// Execute the application.
|
||||
$app->execute();
|
||||
|
|
|
@ -40,4 +40,4 @@ $container = \Joomla\CMS\Factory::getContainer();
|
|||
$container->registerServiceProvider(new \Joomla\CMS\Installation\Service\Provider\Application);
|
||||
|
||||
// Instantiate and execute the application
|
||||
$container->get('InstallationApplicationWeb')->execute();
|
||||
$container->get(\Joomla\CMS\Installation\Application\InstallationApplication::class)->execute();
|
||||
|
|
|
@ -38,7 +38,7 @@ class Application implements ServiceProviderInterface
|
|||
public function register(Container $container)
|
||||
{
|
||||
$container->share(
|
||||
'InstallationApplicationWeb',
|
||||
InstallationApplication::class,
|
||||
function (Container $container)
|
||||
{
|
||||
$config = null;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Joomla\CMS;
|
|||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Application\CMSApplicationInterface;
|
||||
use Joomla\CMS\Cache\Cache;
|
||||
use Joomla\CMS\Date\Date;
|
||||
use Joomla\CMS\Document\Document;
|
||||
|
@ -38,7 +38,7 @@ abstract class Factory
|
|||
/**
|
||||
* Global application object
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @var CMSApplicationInterface
|
||||
* @since 11.1
|
||||
*/
|
||||
public static $application = null;
|
||||
|
@ -118,38 +118,20 @@ abstract class Factory
|
|||
public static $mailer = null;
|
||||
|
||||
/**
|
||||
* Get an application object.
|
||||
* Get the global application object. When the global application doesn't exist, an exception is thrown.
|
||||
*
|
||||
* Returns the global {@link CMSApplication} object, only creating it if it doesn't already exist.
|
||||
* @return CMSApplicationInterface object
|
||||
*
|
||||
* @param mixed $id A client identifier or name.
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* @param string $prefix Application prefix
|
||||
* @param Container $container An optional dependency injection container to inject into the application.
|
||||
*
|
||||
* @return CMSApplication object
|
||||
*
|
||||
* @see JApplication
|
||||
* @since 11.1
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getApplication($id = null, array $config = array(), $prefix = 'JApplication', Container $container = null)
|
||||
public static function getApplication()
|
||||
{
|
||||
if (!self::$application)
|
||||
{
|
||||
if (!$id)
|
||||
{
|
||||
throw new \Exception('Application Instantiation Error', 500);
|
||||
}
|
||||
|
||||
$container = $container ?: self::getContainer();
|
||||
|
||||
self::$application = CMSApplication::getInstance($id, $prefix, $container);
|
||||
|
||||
// Attach a delegated JLog object to the application
|
||||
self::$application->setLogger($container->get(LoggerInterface::class));
|
||||
}
|
||||
|
||||
return self::$application;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user