29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-28 16:13:42 +00:00

Remove arguments of Factory::getApplication as they are misleading (#18898)

This commit is contained in:
Allon Moritz 2018-02-02 17:22:13 +01:00 committed by George Wilson
parent 2794f611c4
commit 58e19566a1
5 changed files with 17 additions and 29 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -38,7 +38,7 @@ class Application implements ServiceProviderInterface
public function register(Container $container)
{
$container->share(
'InstallationApplicationWeb',
InstallationApplication::class,
function (Container $container)
{
$config = null;

View File

@ -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,36 +118,18 @@ 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));
throw new \Exception('Application Instantiation Error', 500);
}
return self::$application;