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
100 changes: 0 additions & 100 deletions libraries/src/Application/Autoconfigurable.php

This file was deleted.

5 changes: 1 addition & 4 deletions libraries/src/Application/CliApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
abstract class CliApplication extends AbstractApplication implements DispatcherAwareInterface, CMSApplicationInterface
{
use Autoconfigurable, DispatcherAwareTrait, EventAware, IdentityAware, ContainerAwareTrait;
use DispatcherAwareTrait, EventAware, IdentityAware, ContainerAwareTrait;

/**
* Output object
Expand Down Expand Up @@ -102,9 +102,6 @@ public function __construct(Input $input = null, Registry $config = null, CliOut
// Set the current directory.
$this->set('cwd', getcwd());

// Load the configuration object.
$this->loadConfiguration($this->fetchConfigurationData());

// Set up the environment
$this->input->set('format', 'cli');
}
Expand Down
5 changes: 1 addition & 4 deletions libraries/src/Application/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
class ConsoleApplication extends Application implements DispatcherAwareInterface, CMSApplicationInterface
{
use Autoconfigurable, DispatcherAwareTrait, EventAware, IdentityAware, ContainerAwareTrait;
use DispatcherAwareTrait, EventAware, IdentityAware, ContainerAwareTrait;

/**
* The application message queue.
Expand Down Expand Up @@ -80,9 +80,6 @@ public function __construct(Cli $input = null, Registry $config = null, Dispatch
$this->setDispatcher($dispatcher);
}

// Load the configuration object.
$this->loadConfiguration($this->fetchConfigurationData());

// Set the execution datetime and timestamp;
$this->set('execution.datetime', gmdate('Y-m-d H:i:s'));
$this->set('execution.timestamp', time());
Expand Down
17 changes: 13 additions & 4 deletions libraries/src/Application/WebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
abstract class WebApplication extends AbstractWebApplication implements DispatcherAwareInterface
{
use Autoconfigurable, DispatcherAwareTrait, EventAware, IdentityAware;
use DispatcherAwareTrait, EventAware, IdentityAware;

/**
* The application document object.
Expand Down Expand Up @@ -81,9 +81,6 @@ public function __construct(Input $input = null, Registry $config = null, WebCli

parent::__construct($input, $config, $client, $response);

// Load the configuration object.
$this->loadConfiguration($this->fetchConfigurationData());

// Set the execution datetime and timestamp;
$this->set('execution.datetime', gmdate('Y-m-d H:i:s'));
$this->set('execution.timestamp', time());
Expand Down Expand Up @@ -422,4 +419,16 @@ protected function loadSystemUris($requestUri = null)
$this->set('uri.media.path', $this->get('uri.base.path') . 'media/');
}
}

/**
* Retrieve the application configuration object.
*
* @return Registry
*
* @since __DEPLOY_VERSION__
*/
public function getConfig()
{
return $this->config;
}
}
1 change: 1 addition & 0 deletions libraries/src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ protected static function createContainer(): Container
$container = (new Container)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Application)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Authentication)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Config)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Console)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Database)
->registerServiceProvider(new \Joomla\CMS\Service\Provider\Dispatcher)
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Service/Provider/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function register(Container $container)
'JApplicationAdministrator',
function (Container $container)
{
$app = new AdministratorApplication(null, null, null, $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)
Expand All @@ -71,7 +71,7 @@ function (Container $container)
'JApplicationSite',
function (Container $container)
{
$app = new SiteApplication(null, null, null, $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)
Expand All @@ -93,7 +93,7 @@ function (Container $container)
BaseConsoleApplication::class,
function (Container $container)
{
$app = new ConsoleApplication;
$app = new ConsoleApplication(null, $container->get('config'));

$dispatcher = $container->get('Joomla\Event\DispatcherInterface');

Expand Down
57 changes: 57 additions & 0 deletions libraries/src/Service/Provider/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2017 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\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Registry\Registry;

/**
* Service provider for the application's config dependency
*
* @since 4.0
*/
class Config 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('config', 'JConfig')
->share(
'JConfig',
function (Container $container)
{
if (!file_exists(JPATH_CONFIGURATION . '/configuration.php'))
{
return [];
}

\JLoader::register('JConfig', JPATH_CONFIGURATION . '/configuration.php');

if (!class_exists('JConfig'))
{
throw new \RuntimeException('Configuration class does not exist.');
}

return new Registry(new \JConfig);
},
true
);
}
}
2 changes: 1 addition & 1 deletion libraries/src/Service/Provider/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function register(Container $container)
DatabaseInterface::class,
function (Container $container)
{
$conf = \JFactory::getConfig();
$conf = $container->get('config');

$dbtype = $conf->get('dbtype');

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Service/Provider/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function register(Container $container)
'Joomla\Session\SessionInterface',
function (Container $container)
{
$config = Factory::getConfig();
$config = $container->get('config');
$app = Factory::getApplication();

// Generate a session name.
Expand Down