Skip to content

Commit

Permalink
Introduce extension loader interface
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Feb 14, 2018
1 parent 3282e31 commit a057199
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 19 deletions.
4 changes: 2 additions & 2 deletions administrator/components/com_content/services/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
defined('_JEXEC') or die;

$container->share(
'ContentContainer',
'ContentComponentContainer',
function (\Joomla\DI\Container $parent)
{
$container = new \Joomla\CMS\Component\ComponentContainer($parent);
$container = new \Joomla\CMS\Extension\ComponentContainer($parent);
$container->set('categories', new \Joomla\Component\Content\Site\Service\Category);

return $container;
Expand Down
3 changes: 2 additions & 1 deletion libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Authentication\Authentication;
use Joomla\CMS\Event\AbstractEvent;
use Joomla\CMS\Event\BeforeExecuteEvent;
use Joomla\CMS\Extension\ExtensionLoader;
use Joomla\CMS\Input\Input;
use Joomla\CMS\Language\Language;
use Joomla\CMS\Menu\AbstractMenu;
Expand All @@ -35,7 +36,7 @@
*/
abstract class CMSApplication extends WebApplication implements ContainerAwareInterface, CMSApplicationInterface
{
use ContainerAwareTrait, ExtensionNamespaceMapper;
use ExtensionLoader, ExtensionNamespaceMapper;

/**
* Array of options for the \JDocument object
Expand Down
3 changes: 2 additions & 1 deletion libraries/src/Application/CMSApplicationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Joomla\CMS\Application;

use Joomla\CMS\Extension\ExtensionLoaderInterface;
use Joomla\CMS\User\User;
use Joomla\Session\SessionInterface;

Expand All @@ -16,7 +17,7 @@
*
* @since 4.0.0
*/
interface CMSApplicationInterface
interface CMSApplicationInterface extends ExtensionLoaderInterface
{
/**
* Constant defining an enqueued emergency message
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Application/CliApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
use Joomla\CMS\Application\CLI\CliInput;
use Joomla\CMS\Application\CLI\CliOutput;
use Joomla\CMS\Application\CLI\Output\Stdout;
use Joomla\CMS\Extension\ExtensionLoader;
use Joomla\Input\Cli;
use Joomla\Input\Input;
use Joomla\DI\Container;
use Joomla\DI\ContainerAwareTrait;
use Joomla\Event\DispatcherAwareInterface;
use Joomla\Event\DispatcherAwareTrait;
use Joomla\Event\DispatcherInterface;
Expand All @@ -32,7 +32,7 @@
*/
abstract class CliApplication extends AbstractApplication implements DispatcherAwareInterface, CMSApplicationInterface
{
use DispatcherAwareTrait, EventAware, IdentityAware, ContainerAwareTrait;
use DispatcherAwareTrait, EventAware, IdentityAware, ExtensionLoader;

/**
* Output object
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Application/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Console;
use Joomla\CMS\Extension\ExtensionLoader;
use Joomla\CMS\Input\Cli;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Console\Application;
use Joomla\DI\Container;
use Joomla\DI\ContainerAwareTrait;
use Joomla\Event\DispatcherAwareInterface;
use Joomla\Event\DispatcherAwareTrait;
use Joomla\Event\DispatcherInterface;
Expand All @@ -30,7 +30,7 @@
*/
class ConsoleApplication extends Application implements DispatcherAwareInterface, CMSApplicationInterface
{
use DispatcherAwareTrait, EventAware, IdentityAware, ContainerAwareTrait;
use DispatcherAwareTrait, EventAware, IdentityAware, ExtensionLoader;

/**
* The application message queue.
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Categories/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static function getInstance($extension, $options = array())

$parts = explode('.', $extension, 2);

$categories = ComponentHelper::boot($parts[0])->getCategories(count($parts) > 1 ? $parts[1] : '');
$categories = Factory::getApplication()->bootComponent($parts[0])->getCategories(count($parts) > 1 ? $parts[1] : '');

if ($categories)
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Extension/ComponentContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Component;
namespace Joomla\CMS\Extension;

defined('JPATH_PLATFORM') or die;

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Extension/ComponentContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Component;
namespace Joomla\CMS\Extension;

defined('JPATH_PLATFORM') or die;

Expand Down
4 changes: 1 addition & 3 deletions libraries/src/Extension/ExtensionContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Component;
namespace Joomla\CMS\Extension;

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Extension\Extension;

/**
* Access to component specific services.
*
Expand Down
1 change: 0 additions & 1 deletion libraries/src/Extension/ExtensionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Component\ExtensionContainerInterface;
use Joomla\DI\ContainerAwareTrait;

/**
Expand Down
30 changes: 30 additions & 0 deletions libraries/src/Extension/ExtensionLoaderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\Extension;

defined('JPATH_PLATFORM') or die;

/**
* Loads extensions.
*
* @since __DEPLOY_VERSION__
*/
interface ExtensionLoaderInterface
{
/**
* Boots the component with the given name.
*
* @param string $component The component to boot.
*
* @return ComponentContainerInterface
*
* @since __DEPLOY_VERSION__
*/
public function bootComponent($component): ComponentContainerInterface;
}
2 changes: 1 addition & 1 deletion libraries/src/Extension/LegacyComponentContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Component;
namespace Joomla\CMS\Extension;

defined('JPATH_PLATFORM') or die;

Expand Down
6 changes: 3 additions & 3 deletions libraries/src/MVC/Model/BaseDatabaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Component\ComponentContainerInterface;
use Joomla\CMS\Extension\ComponentContainerInterface;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Factory\LegacyFactory;
use Joomla\CMS\MVC\Factory\MVCFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
Expand Down Expand Up @@ -670,7 +671,6 @@ protected function cleanCache($group = null, $client_id = 0)
*/
protected function bootComponent($component): ComponentContainerInterface
{
// @Todo move the static call to an interface
return ComponentHelper::boot($component);
return Factory::getApplication()->bootComponent($component);
}
}

0 comments on commit a057199

Please sign in to comment.