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
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\Component;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use Joomla\CMS\MVC\Factory\MVCFactoryServiceTrait;
use Joomla\CMS\MVC\Factory\MVCFactoryServiceInterface;
use Joomla\Component\Admin\Administrator\Service\HTML\Directory;
use Joomla\Component\Admin\Administrator\Service\HTML\PhpSetting;
use Joomla\Component\Admin\Administrator\Service\HTML\System;
Expand All @@ -26,9 +24,8 @@
*
* @since 4.0.0
*/
class AdminComponent extends Component implements BootableExtensionInterface, MVCFactoryServiceInterface
class AdminComponent extends MVCComponent implements BootableExtensionInterface
{
use MVCFactoryServiceTrait;
use HTMLRegistryAwareTrait;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,29 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Associations\Administrator\Dispatcher;

defined('_JEXEC') or die;

use Joomla\CMS\Access\Exception\Notallowed;
use Joomla\CMS\Dispatcher\Dispatcher;
use Joomla\CMS\Language\Text;
use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;

/**
* Dispatcher class for com_associations
*
* @since 4.0.0
*/
class AssociationsDispatcher extends Dispatcher
class Dispatcher extends \Joomla\CMS\Dispatcher\Dispatcher
{
/**
* The extension namespace
*
* @var string
*
* @since 4.0.0
*/
protected $namespace = 'Joomla\\Component\\Associations';

/**
* Method to check component access permission
*
* @since 4.0.0
*
* @return void
*
* @throws Exception|Notallowed
* @throws \Exception|Notallowed
*/
protected function checkAccess()
{
Expand All @@ -51,12 +44,15 @@ protected function checkAccess()

if (!AssociationsHelper::hasSupport($extensionName))
{
throw new Exception(JText::sprintf('COM_ASSOCIATIONS_COMPONENT_NOT_SUPPORTED', JText::_($extensionName)), 404);
throw new \Exception(
Text::sprintf('COM_ASSOCIATIONS_COMPONENT_NOT_SUPPORTED', $this->app->getLanguage()->_($extensionName)),
404
);
}

if (!JFactory::getUser()->authorise('core.manage', $extensionName))
if (!$this->app->getIdentity()->authorise('core.manage', $extensionName))
{
throw new Notallowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
}
}
}
Expand Down
54 changes: 54 additions & 0 deletions administrator/components/com_associations/services/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_associations
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\DispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Extension\Service\Provider\DispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactoryFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

/**
* The associations service provider.
*
* @since 4.0.0
*/
return new class implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->registerServiceProvider(new MVCFactoryFactory('\\Joomla\\Component\\Associations'));
$container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Associations'));

$container->set(
ComponentInterface::class,
function (Container $container)
{
$component = new MVCComponent($container->get(DispatcherFactoryInterface::class));

$component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class));

return $component;
}
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
use Joomla\CMS\Categories\CategoriesServiceInterface;
use Joomla\CMS\Categories\CategoriesServiceTrait;
use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\Component;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Fields\FieldsServiceInterface;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use Joomla\CMS\MVC\Factory\MVCFactoryServiceTrait;
use Joomla\CMS\MVC\Factory\MVCFactoryServiceInterface;
use Joomla\Component\Content\Administrator\Service\HTML\AdministratorService;
use Joomla\Component\Content\Administrator\Service\HTML\Icon;
use Psr\Container\ContainerInterface;
Expand All @@ -31,10 +29,9 @@
*
* @since 4.0.0
*/
class ContentComponent extends Component implements
BootableExtensionInterface, MVCFactoryServiceInterface, CategoriesServiceInterface, FieldsServiceInterface, AssociationServiceInterface
class ContentComponent extends MVCComponent implements
BootableExtensionInterface, CategoriesServiceInterface, FieldsServiceInterface, AssociationServiceInterface
{
use MVCFactoryServiceTrait;
use CategoriesServiceTrait;
use AssociationServiceTrait;
use HTMLRegistryAwareTrait;
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions administrator/components/com_modules/services/provider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_content
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
Expand All @@ -11,10 +11,10 @@

use Joomla\CMS\Dispatcher\DispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Extension\Service\Provider\DispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactoryFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryFactoryInterface;
use Joomla\Component\Modules\Administrator\Extension\ModulesComponent;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

Expand Down Expand Up @@ -43,7 +43,7 @@ public function register(Container $container)
ComponentInterface::class,
function (Container $container)
{
$component = new ModulesComponent($container->get(DispatcherFactoryInterface::class));
$component = new MVCComponent($container->get(DispatcherFactoryInterface::class));

$component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class));

Expand Down
24 changes: 24 additions & 0 deletions libraries/src/Extension/MVCComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2018 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;

use Joomla\CMS\MVC\Factory\MVCFactoryServiceInterface;
use Joomla\CMS\MVC\Factory\MVCFactoryServiceTrait;

/**
* MVC Component class.
*
* @since __DEPLOY_VERSION__
*/
class MVCComponent extends Component implements MVCFactoryServiceInterface
{
use MVCFactoryServiceTrait;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want to keep the trait as it is used only here anymore?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so - people might still choose to build up their own hierarchy of classes for their component implementations

}