From 9eb8e99bcce80486b413c4896b6b884471fdde11 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Mon, 6 Aug 2018 15:31:31 +0200 Subject: [PATCH] Change content history to services --- .../Dispatcher.php} | 18 +++---- .../helpers/contenthistory.php | 4 +- .../com_contenthistory/services/provider.php | 54 +++++++++++++++++++ .../Controller/DisplayController.php | 41 ++++++++++++++ .../Dispatcher.php} | 22 ++++---- 5 files changed, 113 insertions(+), 26 deletions(-) rename administrator/components/com_contenthistory/{dispatcher.php => Dispatcher/Dispatcher.php} (72%) create mode 100644 administrator/components/com_contenthistory/services/provider.php create mode 100644 components/com_contenthistory/Controller/DisplayController.php rename components/com_contenthistory/{dispatcher.php => Dispatcher/Dispatcher.php} (81%) diff --git a/administrator/components/com_contenthistory/dispatcher.php b/administrator/components/com_contenthistory/Dispatcher/Dispatcher.php similarity index 72% rename from administrator/components/com_contenthistory/dispatcher.php rename to administrator/components/com_contenthistory/Dispatcher/Dispatcher.php index eb87c19b77983..ea633b86b3255 100644 --- a/administrator/components/com_contenthistory/dispatcher.php +++ b/administrator/components/com_contenthistory/Dispatcher/Dispatcher.php @@ -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() { diff --git a/administrator/components/com_contenthistory/helpers/contenthistory.php b/administrator/components/com_contenthistory/helpers/contenthistory.php index a276a7206cb83..c738d556824ea 100644 --- a/administrator/components/com_contenthistory/helpers/contenthistory.php +++ b/administrator/components/com_contenthistory/helpers/contenthistory.php @@ -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 { diff --git a/administrator/components/com_contenthistory/services/provider.php b/administrator/components/com_contenthistory/services/provider.php new file mode 100644 index 0000000000000..12202354091e9 --- /dev/null +++ b/administrator/components/com_contenthistory/services/provider.php @@ -0,0 +1,54 @@ +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; + } + ); + } +}; diff --git a/components/com_contenthistory/Controller/DisplayController.php b/components/com_contenthistory/Controller/DisplayController.php new file mode 100644 index 0000000000000..71d9d39f4b826 --- /dev/null +++ b/components/com_contenthistory/Controller/DisplayController.php @@ -0,0 +1,41 @@ +app->getIdentity()->guest) { throw new Notallowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403); @@ -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); }