Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion administrator/includes/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
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();
7 changes: 5 additions & 2 deletions includes/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
// 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();
2 changes: 1 addition & 1 deletion installation/includes/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
$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();
2 changes: 1 addition & 1 deletion installation/src/Service/Provider/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Application implements ServiceProviderInterface
public function register(Container $container)
{
$container->share(
'InstallationApplicationWeb',
InstallationApplication::class,
function (Container $container)
{
$config = null;
Expand Down
30 changes: 6 additions & 24 deletions libraries/src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

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;
Expand Down Expand Up @@ -38,7 +38,7 @@ abstract class Factory
/**
* Global application object
*
* @var CMSApplication
* @var CMSApplicationInterface
* @since 11.1
*/
public static $application = null;
Expand Down Expand Up @@ -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;
Expand Down