Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Change com_contenthistory to services #21418

Merged
merged 2 commits into from
Aug 7, 2018
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 @@ -7,33 +7,27 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Contenthistory\Administrator\Dispatcher;

defined('_JEXEC') or die;

use Joomla\CMS\Access\Exception\Notallowed;
use Joomla\CMS\Dispatcher\Dispatcher;

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

/**
* Method to check component access permission
*
* @since 4.0.0
*
* @return void
*
* @throws \Exception|Notallowed
*/
protected function checkAccess()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
/**
* Categories helper.
*
* @since 3.2
* @since 3.2
*
* @deprecated 5.0 Use \Joomla\Component\Contenthistory\Administrator\Helper\ContenthistoryHelper instead
*/
class ContenthistoryHelper extends \Joomla\Component\Contenthistory\Administrator\Helper\ContenthistoryHelper
{
Expand Down
54 changes: 54 additions & 0 deletions administrator/components/com_contenthistory/services/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_banners
*
* @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 content history 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\\Contenthistory'));
$container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Contenthistory'));

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

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

return $component;
}
);
}
};
41 changes: 41 additions & 0 deletions components/com_contenthistory/Controller/DisplayController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_contenthistory
*
* @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\Component\Contenthistory\Site\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;

/**
* History manager master display controller.
*
* @since 4.0
*/
class DisplayController extends BaseController
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The JApplication for the dispatcher
* @param \JInput $input Input
*
* @since 3.0
*/
public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
{
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;

parent::__construct($config, $factory, $app, $input);
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
<?php
/**
* @package Joomla.Administrator
* @package Joomla.Site
* @subpackage com_contenthistory
*
* @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\Component\Contenthistory\Site\Dispatcher;

defined('_JEXEC') or die;

use Joomla\CMS\Access\Exception\Notallowed;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Dispatcher\Dispatcher;

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

/**
* Load the language
*
Expand All @@ -49,9 +41,12 @@ protected function loadLanguage()
* @since 4.0.0
*
* @return void
*
* @throws \Exception|Notallowed
*/
protected function checkAccess()
{
// Check the user has permission to access this component if in the backend
if ($this->app->getIdentity()->guest)
{
throw new Notallowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
Expand All @@ -72,6 +67,7 @@ protected function checkAccess()
public function getController(string $name, string $client = '', array $config = array()): BaseController
{
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
$client = 'Administrator';

return parent::getController($name, $client, $config);
}
Expand Down