From 94d9d73d74d60f279de231b81a5d17f81c47f803 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Fri, 8 Jun 2018 13:48:23 +0200 Subject: [PATCH 01/12] Introduce category factory --- .../com_content/services/provider.php | 8 +-- components/com_content/Service/Category.php | 36 ----------- .../src/Categories/CategoriesFactory.php | 61 ++++++++++++++++++ .../Categories/CategoriesFactoryInterface.php | 32 ++++++++++ .../src/Categories/CategoriesServiceTrait.php | 27 +++----- .../Service/Provider/CategoriesFactory.php | 64 +++++++++++++++++++ 6 files changed, 171 insertions(+), 57 deletions(-) delete mode 100644 components/com_content/Service/Category.php create mode 100644 libraries/src/Categories/CategoriesFactory.php create mode 100644 libraries/src/Categories/CategoriesFactoryInterface.php create mode 100644 libraries/src/Extension/Service/Provider/CategoriesFactory.php diff --git a/administrator/components/com_content/services/provider.php b/administrator/components/com_content/services/provider.php index 54ec867702858..a16dc85294993 100644 --- a/administrator/components/com_content/services/provider.php +++ b/administrator/components/com_content/services/provider.php @@ -10,16 +10,16 @@ defined('_JEXEC') or die; use Joomla\CMS\Association\AssociationExtensionInterface; -use Joomla\CMS\Categories\Categories; +use Joomla\CMS\Categories\CategoriesFactoryInterface; use Joomla\CMS\Dispatcher\DispatcherFactoryInterface; use Joomla\CMS\Extension\ComponentInterface; +use Joomla\CMS\Extension\Service\Provider\CategoriesFactory; use Joomla\CMS\Extension\Service\Provider\DispatcherFactory; use Joomla\CMS\Extension\Service\Provider\MVCFactoryFactory; use Joomla\CMS\HTML\Registry; use Joomla\CMS\MVC\Factory\MVCFactoryFactoryInterface; use Joomla\Component\Content\Administrator\Extension\ContentComponent; use Joomla\Component\Content\Administrator\Helper\AssociationsHelper; -use Joomla\Component\Content\Site\Service\Category; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; @@ -41,9 +41,9 @@ */ public function register(Container $container) { - $container->set(Categories::class, ['' => new Category]); $container->set(AssociationExtensionInterface::class, new AssociationsHelper); + $container->registerServiceProvider(new CategoriesFactory(['table' => '#__content', 'extension' => 'com_content'])); $container->registerServiceProvider(new MVCFactoryFactory('\\Joomla\\Component\\Content')); $container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Content')); @@ -55,7 +55,7 @@ function (Container $container) $component->setRegistry($container->get(Registry::class)); $component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class)); - $component->setCategories($container->get(Categories::class)); + $component->setCategoriesFactory($container->get(CategoriesFactoryInterface::class)); $component->setAssociationExtension($container->get(AssociationExtensionInterface::class)); return $component; diff --git a/components/com_content/Service/Category.php b/components/com_content/Service/Category.php deleted file mode 100644 index e02ed251352db..0000000000000 --- a/components/com_content/Service/Category.php +++ /dev/null @@ -1,36 +0,0 @@ -options = $options; + } + + /** + * Creates a category. + * + * @param string $section The section + * + * @return Categories + * + * @since __DEPLOY_VERSION__ + * + * @throws SectionNotFoundException + */ + public function createCategory(string $section): Categories + { + if (!array_key_exists($section, $this->options)) + { + throw new SectionNotFoundException; + } + + return new Categories($this->options[$section]); + } +} diff --git a/libraries/src/Categories/CategoriesFactoryInterface.php b/libraries/src/Categories/CategoriesFactoryInterface.php new file mode 100644 index 0000000000000..6b611dd45f36e --- /dev/null +++ b/libraries/src/Categories/CategoriesFactoryInterface.php @@ -0,0 +1,32 @@ +categories)) - { - throw new SectionNotFoundException; - } - - $categories = clone $this->categories[$section]; - $categories->setOptions($options); + $category = $this->categoriesFactory->createCategory($section); + $category->setOptions($options); - return $categories; + return $category; } /** - * An array of categories where the key is the name of the section. - * If the component has no sections then the array must have at least - * an empty key. + * Sets the internal categories factory. * - * @param array $categories The categories + * @param CategoriesFactoryInterface $categoriesFactory The categories factory * * @return void * * @since 4.0.0 */ - public function setCategories(array $categories) + public function setCategoriesFactory(CategoriesFactoryInterface $categoriesFactory) { - $this->categories = $categories; + $this->categoriesFactory = $categoriesFactory; } /** diff --git a/libraries/src/Extension/Service/Provider/CategoriesFactory.php b/libraries/src/Extension/Service/Provider/CategoriesFactory.php new file mode 100644 index 0000000000000..dd0bdeb1d3606 --- /dev/null +++ b/libraries/src/Extension/Service/Provider/CategoriesFactory.php @@ -0,0 +1,64 @@ +options = $options; + } + + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function register(Container $container) + { + $container->set( + CategoriesFactoryInterface::class, + function (Container $container) + { + return new \Joomla\CMS\Categories\CategoriesFactory(['', $this->options]); + } + ); + } +} From b082c7962579221bbd603cbb2ebb7c5e46b1dafb Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 17 Jul 2018 09:05:18 +0200 Subject: [PATCH 02/12] Adapt banners --- .../com_banners/services/provider.php | 9 +++-- components/com_banners/Service/Category.php | 36 ------------------- 2 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 components/com_banners/Service/Category.php diff --git a/administrator/components/com_banners/services/provider.php b/administrator/components/com_banners/services/provider.php index d07b01a012442..cc8962574ca30 100644 --- a/administrator/components/com_banners/services/provider.php +++ b/administrator/components/com_banners/services/provider.php @@ -9,15 +9,15 @@ defined('_JEXEC') or die; -use Joomla\CMS\Categories\Categories; +use Joomla\CMS\Categories\CategoriesFactoryInterface; use Joomla\CMS\Dispatcher\DispatcherFactoryInterface; use Joomla\CMS\Extension\ComponentInterface; +use Joomla\CMS\Extension\Service\Provider\CategoriesFactory; use Joomla\CMS\Extension\Service\Provider\DispatcherFactory; use Joomla\CMS\Extension\Service\Provider\MVCFactoryFactory; use Joomla\CMS\HTML\Registry; use Joomla\CMS\MVC\Factory\MVCFactoryFactoryInterface; use Joomla\Component\Banners\Administrator\Extension\BannersComponent; -use Joomla\Component\Banners\Site\Service\Category; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; @@ -39,8 +39,7 @@ */ public function register(Container $container) { - $container->set(Categories::class, ['' => new Category]); - + $container->registerServiceProvider(new CategoriesFactory(['table' => '#__banners', 'extension' => 'com_banners'])); $container->registerServiceProvider(new MVCFactoryFactory('\\Joomla\\Component\\Banners')); $container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Banners')); @@ -52,7 +51,7 @@ function (Container $container) $component->setRegistry($container->get(Registry::class)); $component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class)); - $component->setCategories($container->get(Categories::class)); + $component->setCategoriesFactory($container->get(CategoriesFactoryInterface::class)); return $component; } diff --git a/components/com_banners/Service/Category.php b/components/com_banners/Service/Category.php deleted file mode 100644 index aacf5829d6ca2..0000000000000 --- a/components/com_banners/Service/Category.php +++ /dev/null @@ -1,36 +0,0 @@ - Date: Tue, 17 Jul 2018 09:36:40 +0200 Subject: [PATCH 03/12] Introduce CategoryInterface --- .../com_fields/Model/FieldModel.php | 2 +- libraries/src/Categories/Categories.php | 19 ++++---- .../src/Categories/CategoriesFactory.php | 4 +- .../Categories/CategoriesFactoryInterface.php | 4 +- .../Categories/CategoriesServiceInterface.php | 6 +-- .../src/Categories/CategoriesServiceTrait.php | 6 +-- .../src/Categories/CategoryInterface.php | 45 +++++++++++++++++++ .../Categories/CategoryNotFoundException.php | 18 ++++++++ libraries/src/Extension/LegacyComponent.php | 8 ++-- .../Service/Provider/CategoriesFactory.php | 2 +- 10 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 libraries/src/Categories/CategoryInterface.php create mode 100644 libraries/src/Categories/CategoryNotFoundException.php diff --git a/administrator/components/com_fields/Model/FieldModel.php b/administrator/components/com_fields/Model/FieldModel.php index efaec5c376774..342924aa40e6e 100644 --- a/administrator/components/com_fields/Model/FieldModel.php +++ b/administrator/components/com_fields/Model/FieldModel.php @@ -981,7 +981,7 @@ protected function preprocessForm(\JForm $form, $data, $group = 'content') throw new SectionNotFoundException; } - $cat = $componentObject->getCategories(); + $cat = $componentObject->getCategory(); if ($cat->get('root')->hasChildren()) { diff --git a/libraries/src/Categories/Categories.php b/libraries/src/Categories/Categories.php index 52746a2705606..595f84d261690 100644 --- a/libraries/src/Categories/Categories.php +++ b/libraries/src/Categories/Categories.php @@ -18,7 +18,7 @@ * * @since 1.6 */ -class Categories +class Categories implements CategoryInterface { /** * Array to hold the object instances @@ -146,7 +146,7 @@ public static function getInstance($extension, $options = array()) if ($component instanceof CategoriesServiceInterface) { - $categories = $component->getCategories($options, count($parts) > 1 ? $parts[1] : ''); + $categories = $component->getCategory($options, count($parts) > 1 ? $parts[1] : ''); } } catch (SectionNotFoundException $e) @@ -160,16 +160,18 @@ public static function getInstance($extension, $options = array()) } /** - * Loads a specific category and all its children in a CategoryNode object + * Loads a specific category and all its children in a CategoryNode object. * * @param mixed $id an optional id integer or equal to 'root' * @param boolean $forceload True to force the _load method to execute * - * @return CategoryNode|null|boolean CategoryNode object or null if $id is not valid + * @return CategoryNode CategoryNode object * * @since 1.6 + * + * @throws CategoryNotFoundException */ - public function get($id = 'root', $forceload = false) + public function get($id = 'root', $forceload = false): CategoryNode { if ($id !== 'root') { @@ -192,13 +194,8 @@ public function get($id = 'root', $forceload = false) { return $this->_nodes[$id]; } - // If we processed this $id already and it was not valid, then return null. - elseif (isset($this->_checkedCategories[$id])) - { - return; - } - return false; + throw new CategoryNotFoundException; } /** diff --git a/libraries/src/Categories/CategoriesFactory.php b/libraries/src/Categories/CategoriesFactory.php index ecc081a91e84f..0638f232786fd 100644 --- a/libraries/src/Categories/CategoriesFactory.php +++ b/libraries/src/Categories/CategoriesFactory.php @@ -43,13 +43,13 @@ public function __construct(array $options) * * @param string $section The section * - * @return Categories + * @return CategoryInterface * * @since __DEPLOY_VERSION__ * * @throws SectionNotFoundException */ - public function createCategory(string $section): Categories + public function createCategory(string $section): CategoryInterface { if (!array_key_exists($section, $this->options)) { diff --git a/libraries/src/Categories/CategoriesFactoryInterface.php b/libraries/src/Categories/CategoriesFactoryInterface.php index 6b611dd45f36e..0ec5e0d1fc1a0 100644 --- a/libraries/src/Categories/CategoriesFactoryInterface.php +++ b/libraries/src/Categories/CategoriesFactoryInterface.php @@ -22,11 +22,11 @@ interface CategoriesFactoryInterface * * @param string $section The section * - * @return Categories + * @return CategoryInterface * * @since __DEPLOY_VERSION__ * * @throws SectionNotFoundException */ - public function createCategory(string $section): Categories; + public function createCategory(string $section): CategoryInterface; } diff --git a/libraries/src/Categories/CategoriesServiceInterface.php b/libraries/src/Categories/CategoriesServiceInterface.php index 42dd144ae8934..6e84a32b133c5 100644 --- a/libraries/src/Categories/CategoriesServiceInterface.php +++ b/libraries/src/Categories/CategoriesServiceInterface.php @@ -23,14 +23,14 @@ interface CategoriesServiceInterface * @param array $options The options * @param string $section The section * - * @return Categories + * @return CategoryInterface * - * @see Categories::setOptions() + * @see CategoryInterface::setOptions() * * @since 4.0.0 * @throws SectionNotFoundException */ - public function getCategories(array $options = [], $section = ''): Categories; + public function getCategory(array $options = [], $section = ''): CategoryInterface; /** * Adds Count Items for Category Manager. diff --git a/libraries/src/Categories/CategoriesServiceTrait.php b/libraries/src/Categories/CategoriesServiceTrait.php index fd8367da397ef..b54f53d74dd57 100644 --- a/libraries/src/Categories/CategoriesServiceTrait.php +++ b/libraries/src/Categories/CategoriesServiceTrait.php @@ -32,14 +32,14 @@ trait CategoriesServiceTrait * @param array $options The options * @param string $section The section * - * @return Categories + * @return CategoryInterface * - * @see Categories::setOptions() + * @see CategoryInterface::setOptions() * * @since 4.0.0 * @throws SectionNotFoundException */ - public function getCategories(array $options = [], $section = ''): Categories + public function getCategory(array $options = [], $section = ''): CategoryInterface { $category = $this->categoriesFactory->createCategory($section); $category->setOptions($options); diff --git a/libraries/src/Categories/CategoryInterface.php b/libraries/src/Categories/CategoryInterface.php new file mode 100644 index 0000000000000..9d1521b786e2a --- /dev/null +++ b/libraries/src/Categories/CategoryInterface.php @@ -0,0 +1,45 @@ +component) . ucfirst($section) . 'Categories'; diff --git a/libraries/src/Extension/Service/Provider/CategoriesFactory.php b/libraries/src/Extension/Service/Provider/CategoriesFactory.php index dd0bdeb1d3606..1687794795460 100644 --- a/libraries/src/Extension/Service/Provider/CategoriesFactory.php +++ b/libraries/src/Extension/Service/Provider/CategoriesFactory.php @@ -57,7 +57,7 @@ public function register(Container $container) CategoriesFactoryInterface::class, function (Container $container) { - return new \Joomla\CMS\Categories\CategoriesFactory(['', $this->options]); + return new \Joomla\CMS\Categories\CategoriesFactory(['' => $this->options]); } ); } From 1096d2882d52c80ec0246ac419d9ce7a7444a4ac Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Fri, 31 Aug 2018 11:27:55 +0200 Subject: [PATCH 04/12] Less strict method signature --- libraries/src/Categories/Categories.php | 2 +- libraries/src/Categories/CategoryInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/src/Categories/Categories.php b/libraries/src/Categories/Categories.php index 44eca4f3320ee..e41859f879ad8 100644 --- a/libraries/src/Categories/Categories.php +++ b/libraries/src/Categories/Categories.php @@ -171,7 +171,7 @@ public static function getInstance($extension, $options = array()) * * @throws CategoryNotFoundException */ - public function get($id = 'root', $forceload = false): CategoryNode + public function get($id = 'root', $forceload = false) { if ($id !== 'root') { diff --git a/libraries/src/Categories/CategoryInterface.php b/libraries/src/Categories/CategoryInterface.php index 9d1521b786e2a..22ac6be6de915 100644 --- a/libraries/src/Categories/CategoryInterface.php +++ b/libraries/src/Categories/CategoryInterface.php @@ -29,7 +29,7 @@ interface CategoryInterface * * @throws CategoryNotFoundException */ - public function get($id = 'root', $forceload = false): CategoryNode; + public function get($id = 'root', $forceload = false); /** * Allows to set some optional options, eg. if the access level should be considered. From 970f7fac821769b32fc9f6611237d7028f31ca08 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Fri, 31 Aug 2018 13:14:44 +0200 Subject: [PATCH 05/12] Restore typed classes --- .../com_banners/services/provider.php | 2 +- .../com_content/services/provider.php | 2 +- components/com_banners/Service/Category.php | 37 +++++++++++ components/com_content/Service/Category.php | 37 +++++++++++ libraries/src/Categories/Categories.php | 61 ++++++------------- .../src/Categories/CategoriesFactory.php | 29 +++++---- .../Categories/CategoriesFactoryInterface.php | 3 +- .../src/Categories/CategoriesServiceTrait.php | 5 +- .../src/Categories/CategoryInterface.php | 12 ---- .../Categories/CategoryNotFoundException.php | 18 ------ .../Service/Provider/CategoriesFactory.php | 22 +++---- 11 files changed, 126 insertions(+), 102 deletions(-) create mode 100644 components/com_banners/Service/Category.php create mode 100644 components/com_content/Service/Category.php delete mode 100644 libraries/src/Categories/CategoryNotFoundException.php diff --git a/administrator/components/com_banners/services/provider.php b/administrator/components/com_banners/services/provider.php index 40218af8c2f38..2649382f1e41b 100644 --- a/administrator/components/com_banners/services/provider.php +++ b/administrator/components/com_banners/services/provider.php @@ -39,7 +39,7 @@ */ public function register(Container $container) { - $container->registerServiceProvider(new CategoriesFactory(['table' => '#__banners', 'extension' => 'com_banners'])); + $container->registerServiceProvider(new CategoriesFactory('\\Joomla\\Component\\Banners')); $container->registerServiceProvider(new MVCFactoryFactory('\\Joomla\\Component\\Banners')); $container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Banners')); diff --git a/administrator/components/com_content/services/provider.php b/administrator/components/com_content/services/provider.php index a16dc85294993..0ba9e47589fb0 100644 --- a/administrator/components/com_content/services/provider.php +++ b/administrator/components/com_content/services/provider.php @@ -43,7 +43,7 @@ public function register(Container $container) { $container->set(AssociationExtensionInterface::class, new AssociationsHelper); - $container->registerServiceProvider(new CategoriesFactory(['table' => '#__content', 'extension' => 'com_content'])); + $container->registerServiceProvider(new CategoriesFactory('\\Joomla\\Component\\Banners')); $container->registerServiceProvider(new MVCFactoryFactory('\\Joomla\\Component\\Content')); $container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Content')); diff --git a/components/com_banners/Service/Category.php b/components/com_banners/Service/Category.php new file mode 100644 index 0000000000000..c580eef59c8cb --- /dev/null +++ b/components/com_banners/Service/Category.php @@ -0,0 +1,37 @@ +_statefield = $options['statefield'] ?? 'state'; // Default some optional options - $this->_options['access'] = 'true'; - $this->_options['published'] = 1; - $this->_options['countItems'] = 0; - $this->_options['currentlang'] = Multilanguage::isEnabled() ? Factory::getLanguage()->getTag() : 0; + if (!isset($options['access'])) + { + $this->_options['access'] = 'true'; + } + + if (!isset($options['published'])) + { + $this->_options['published'] = 1; + } + + if (!isset($options['countItems'])) + { + $this->_options['countItems'] = 0; + } - $this->setOptions($options); + if (!isset($options['currentlang'])) + { + $this->_options['currentlang'] = Multilanguage::isEnabled() ? Factory::getLanguage()->getTag() : 0; + } } /** @@ -165,11 +178,9 @@ public static function getInstance($extension, $options = array()) * @param mixed $id an optional id integer or equal to 'root' * @param boolean $forceload True to force the _load method to execute * - * @return CategoryNode CategoryNode object + * @return CategoryNode|null CategoryNode object or null if $id is not valid * * @since 1.6 - * - * @throws CategoryNotFoundException */ public function get($id = 'root', $forceload = false) { @@ -195,7 +206,7 @@ public function get($id = 'root', $forceload = false) return $this->_nodes[$id]; } - throw new CategoryNotFoundException; + return null; } /** @@ -388,36 +399,4 @@ protected function _load($id) $this->_nodes[$id] = null; } } - - /** - * Allows to set some optional options, eg. if the access level should be considered. - * Also clears the internal children cache. - * - * @param array $options The new options - * - * @return void - * - * @since 4.0.0 - */ - public function setOptions(array $options) - { - if (isset($options['access'])) - { - $this->_options['access'] = $options['access']; - } - - if (isset($options['published'])) - { - $this->_options['published'] = $options['published']; - } - - if (isset($options['countItems'])) - { - $this->_options['countItems'] = $options['countItems']; - } - - // Reset the cache - $this->_nodes = []; - $this->_checkedCategories = []; - } } diff --git a/libraries/src/Categories/CategoriesFactory.php b/libraries/src/Categories/CategoriesFactory.php index 0638f232786fd..d3ba12e58e990 100644 --- a/libraries/src/Categories/CategoriesFactory.php +++ b/libraries/src/Categories/CategoriesFactory.php @@ -18,29 +18,30 @@ class CategoriesFactory implements CategoriesFactoryInterface { /** - * The options + * The namespace to create the categories from. * - * @var array - * - * @since __DEPLOY_VERSION__ + * @var string + * @since 4.0.0 */ - private $options; + private $namespace; /** - * CategoriesFactory constructor. + * The namespace must be like: + * Joomla\Component\Content * - * @param array $options The options + * @param string $namespace The namespace * - * @since __DEPLOY_VERSION__ + * @since 4.0.0 */ - public function __construct(array $options) + public function __construct($namespace) { - $this->options = $options; + $this->namespace = $namespace; } /** * Creates a category. * + * @param array $options The options * @param string $section The section * * @return CategoryInterface @@ -49,13 +50,15 @@ public function __construct(array $options) * * @throws SectionNotFoundException */ - public function createCategory(string $section): CategoryInterface + public function createCategory(array $options, string $section): CategoryInterface { - if (!array_key_exists($section, $this->options)) + $className = trim($this->namespace, '\\') . '\\Site\\Service\\' . ucfirst($section) . 'Category'; + + if (!class_exists($className)) { throw new SectionNotFoundException; } - return new Categories($this->options[$section]); + return new $className($options); } } diff --git a/libraries/src/Categories/CategoriesFactoryInterface.php b/libraries/src/Categories/CategoriesFactoryInterface.php index 0ec5e0d1fc1a0..08c95766da2bd 100644 --- a/libraries/src/Categories/CategoriesFactoryInterface.php +++ b/libraries/src/Categories/CategoriesFactoryInterface.php @@ -20,6 +20,7 @@ interface CategoriesFactoryInterface /** * Creates a category. * + * @param array $options The options * @param string $section The section * * @return CategoryInterface @@ -28,5 +29,5 @@ interface CategoriesFactoryInterface * * @throws SectionNotFoundException */ - public function createCategory(string $section): CategoryInterface; + public function createCategory(array $options, string $section): CategoryInterface; } diff --git a/libraries/src/Categories/CategoriesServiceTrait.php b/libraries/src/Categories/CategoriesServiceTrait.php index af87f0fdefa40..7caa97feddc00 100644 --- a/libraries/src/Categories/CategoriesServiceTrait.php +++ b/libraries/src/Categories/CategoriesServiceTrait.php @@ -44,10 +44,7 @@ trait CategoriesServiceTrait */ public function getCategory(array $options = [], $section = ''): CategoryInterface { - $category = $this->categoriesFactory->createCategory($section); - $category->setOptions($options); - - return $category; + return $this->categoriesFactory->createCategory($options, $section); } /** diff --git a/libraries/src/Categories/CategoryInterface.php b/libraries/src/Categories/CategoryInterface.php index 22ac6be6de915..867aeaa615291 100644 --- a/libraries/src/Categories/CategoryInterface.php +++ b/libraries/src/Categories/CategoryInterface.php @@ -30,16 +30,4 @@ interface CategoryInterface * @throws CategoryNotFoundException */ public function get($id = 'root', $forceload = false); - - /** - * Allows to set some optional options, eg. if the access level should be considered. - * Also clears the internal children cache. - * - * @param array $options The new options - * - * @return void - * - * @since __DEPLOY_VERSION__ - */ - public function setOptions(array $options); } diff --git a/libraries/src/Categories/CategoryNotFoundException.php b/libraries/src/Categories/CategoryNotFoundException.php deleted file mode 100644 index 1150fd176cee2..0000000000000 --- a/libraries/src/Categories/CategoryNotFoundException.php +++ /dev/null @@ -1,18 +0,0 @@ -options = $options; + $this->namespace = $namespace; } /** @@ -57,7 +57,7 @@ public function register(Container $container) CategoriesFactoryInterface::class, function (Container $container) { - return new \Joomla\CMS\Categories\CategoriesFactory(['' => $this->options]); + return new \Joomla\CMS\Categories\CategoriesFactory($this->namespace); } ); } From 3a7a6017a1dca2dcad1037e77302d2745c428fea Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Fri, 31 Aug 2018 13:17:38 +0200 Subject: [PATCH 06/12] doc block --- libraries/src/Categories/CategoryInterface.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/src/Categories/CategoryInterface.php b/libraries/src/Categories/CategoryInterface.php index 867aeaa615291..6be835bebc75c 100644 --- a/libraries/src/Categories/CategoryInterface.php +++ b/libraries/src/Categories/CategoryInterface.php @@ -23,11 +23,9 @@ interface CategoryInterface * @param mixed $id an optional id integer or equal to 'root' * @param boolean $forceload True to force the _load method to execute * - * @return CategoryNode CategoryNode object + * @return CategoryNode|null CategoryNode object or null if $id is not valid * * @since __DEPLOY_VERSION__ - * - * @throws CategoryNotFoundException */ public function get($id = 'root', $forceload = false); } From 34b8bfc6af103d4cf35ed75c3866664d6cf1a276 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Fri, 31 Aug 2018 13:19:24 +0200 Subject: [PATCH 07/12] Remove obsolete code --- libraries/src/Categories/CategoriesServiceInterface.php | 2 -- libraries/src/Categories/CategoriesServiceTrait.php | 2 -- libraries/src/Extension/LegacyComponent.php | 2 -- 3 files changed, 6 deletions(-) diff --git a/libraries/src/Categories/CategoriesServiceInterface.php b/libraries/src/Categories/CategoriesServiceInterface.php index 11ffb7393d823..cfd21383edcfc 100644 --- a/libraries/src/Categories/CategoriesServiceInterface.php +++ b/libraries/src/Categories/CategoriesServiceInterface.php @@ -27,8 +27,6 @@ interface CategoriesServiceInterface * * @return CategoryInterface * - * @see CategoryInterface::setOptions() - * * @since 4.0.0 * @throws SectionNotFoundException */ diff --git a/libraries/src/Categories/CategoriesServiceTrait.php b/libraries/src/Categories/CategoriesServiceTrait.php index 7caa97feddc00..7ab998391b7d7 100644 --- a/libraries/src/Categories/CategoriesServiceTrait.php +++ b/libraries/src/Categories/CategoriesServiceTrait.php @@ -37,8 +37,6 @@ trait CategoriesServiceTrait * * @return CategoryInterface * - * @see CategoryInterface::setOptions() - * * @since 4.0.0 * @throws SectionNotFoundException */ diff --git a/libraries/src/Extension/LegacyComponent.php b/libraries/src/Extension/LegacyComponent.php index 2899ddb8b814c..1a7880de961b0 100644 --- a/libraries/src/Extension/LegacyComponent.php +++ b/libraries/src/Extension/LegacyComponent.php @@ -94,8 +94,6 @@ public function createMVCFactory(CMSApplicationInterface $application): MVCFacto * * @return CategoryInterface * - * @see CategoryInterface::setOptions() - * * @since 4.0.0 * @throws SectionNotFoundException */ From a1b8f49e2c64a73aa8bc6bd2645263652c61950f Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 18 Sep 2018 06:22:04 +0200 Subject: [PATCH 08/12] Rename CategoriesServiceTrait to CategoryServiceTrait --- .../components/com_banners/Extension/BannersComponent.php | 4 ++-- .../components/com_content/Extension/ContentComponent.php | 4 ++-- .../{CategoriesServiceTrait.php => CategoryServiceTrait.php} | 2 +- libraries/src/Extension/LegacyComponent.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename libraries/src/Categories/{CategoriesServiceTrait.php => CategoryServiceTrait.php} (99%) diff --git a/administrator/components/com_banners/Extension/BannersComponent.php b/administrator/components/com_banners/Extension/BannersComponent.php index cbdbf53e49fb8..f2469ab11b4e8 100644 --- a/administrator/components/com_banners/Extension/BannersComponent.php +++ b/administrator/components/com_banners/Extension/BannersComponent.php @@ -12,7 +12,7 @@ defined('JPATH_PLATFORM') or die; use Joomla\CMS\Categories\CategoriesServiceInterface; -use Joomla\CMS\Categories\CategoriesServiceTrait; +use Joomla\CMS\Categories\CategoryServiceTrait; use Joomla\CMS\Extension\BootableExtensionInterface; use Joomla\CMS\Extension\MVCComponent; use Joomla\CMS\HTML\HTMLRegistryAwareTrait; @@ -26,7 +26,7 @@ */ class BannersComponent extends MVCComponent implements BootableExtensionInterface, CategoriesServiceInterface { - use CategoriesServiceTrait; + use CategoryServiceTrait; use HTMLRegistryAwareTrait; /** diff --git a/administrator/components/com_content/Extension/ContentComponent.php b/administrator/components/com_content/Extension/ContentComponent.php index e998da072ccfc..370b1308ab7f3 100644 --- a/administrator/components/com_content/Extension/ContentComponent.php +++ b/administrator/components/com_content/Extension/ContentComponent.php @@ -15,7 +15,7 @@ use Joomla\CMS\Association\AssociationServiceTrait; use Joomla\CMS\Association\AssociationServiceInterface; use Joomla\CMS\Categories\CategoriesServiceInterface; -use Joomla\CMS\Categories\CategoriesServiceTrait; +use Joomla\CMS\Categories\CategoryServiceTrait; use Joomla\CMS\Extension\BootableExtensionInterface; use Joomla\CMS\Extension\MVCComponent; use Joomla\CMS\Fields\FieldsServiceInterface; @@ -40,7 +40,7 @@ class ContentComponent extends MVCComponent implements BootableExtensionInterface, MVCFactoryServiceInterface, CategoriesServiceInterface, FieldsServiceInterface, AssociationServiceInterface, WorkflowServiceInterface { - use CategoriesServiceTrait; + use CategoryServiceTrait; use AssociationServiceTrait; use HTMLRegistryAwareTrait; use WorkflowServiceTrait; diff --git a/libraries/src/Categories/CategoriesServiceTrait.php b/libraries/src/Categories/CategoryServiceTrait.php similarity index 99% rename from libraries/src/Categories/CategoriesServiceTrait.php rename to libraries/src/Categories/CategoryServiceTrait.php index 7ab998391b7d7..f05ba40c64034 100644 --- a/libraries/src/Categories/CategoriesServiceTrait.php +++ b/libraries/src/Categories/CategoryServiceTrait.php @@ -18,7 +18,7 @@ * * @since 4.0.0 */ -trait CategoriesServiceTrait +trait CategoryServiceTrait { /** * The categories factory diff --git a/libraries/src/Extension/LegacyComponent.php b/libraries/src/Extension/LegacyComponent.php index 1a7880de961b0..97688e6270e1a 100644 --- a/libraries/src/Extension/LegacyComponent.php +++ b/libraries/src/Extension/LegacyComponent.php @@ -12,7 +12,7 @@ use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\Categories\CategoriesServiceInterface; -use Joomla\CMS\Categories\CategoriesServiceTrait; +use Joomla\CMS\Categories\CategoryServiceTrait; use Joomla\CMS\Categories\CategoryInterface; use Joomla\CMS\Categories\SectionNotFoundException; use Joomla\CMS\Dispatcher\DispatcherInterface; @@ -31,7 +31,7 @@ */ class LegacyComponent implements ComponentInterface, MVCFactoryServiceInterface, CategoriesServiceInterface, FieldsServiceInterface { - use CategoriesServiceTrait; + use CategoryServiceTrait; /** * @var string From ff0b9952cddb3e5eabd36322f62958300e68f889 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 18 Sep 2018 06:23:04 +0200 Subject: [PATCH 09/12] Rename CategoriesServiceInterface to CategoryServiceInterface --- .../components/com_banners/Extension/BannersComponent.php | 4 ++-- .../components/com_categories/Model/CategoriesModel.php | 6 +++--- .../components/com_categories/Model/CategoryModel.php | 6 +++--- .../components/com_content/Extension/ContentComponent.php | 4 ++-- administrator/components/com_fields/Model/FieldModel.php | 4 ++-- administrator/components/com_tags/Model/TagsModel.php | 4 ++-- libraries/src/Categories/Categories.php | 2 +- ...iesServiceInterface.php => CategoryServiceInterface.php} | 2 +- libraries/src/Extension/LegacyComponent.php | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) rename libraries/src/Categories/{CategoriesServiceInterface.php => CategoryServiceInterface.php} (97%) diff --git a/administrator/components/com_banners/Extension/BannersComponent.php b/administrator/components/com_banners/Extension/BannersComponent.php index f2469ab11b4e8..443ac6f02f69a 100644 --- a/administrator/components/com_banners/Extension/BannersComponent.php +++ b/administrator/components/com_banners/Extension/BannersComponent.php @@ -11,7 +11,7 @@ defined('JPATH_PLATFORM') or die; -use Joomla\CMS\Categories\CategoriesServiceInterface; +use Joomla\CMS\Categories\CategoryServiceInterface; use Joomla\CMS\Categories\CategoryServiceTrait; use Joomla\CMS\Extension\BootableExtensionInterface; use Joomla\CMS\Extension\MVCComponent; @@ -24,7 +24,7 @@ * * @since 4.0.0 */ -class BannersComponent extends MVCComponent implements BootableExtensionInterface, CategoriesServiceInterface +class BannersComponent extends MVCComponent implements BootableExtensionInterface, CategoryServiceInterface { use CategoryServiceTrait; use HTMLRegistryAwareTrait; diff --git a/administrator/components/com_categories/Model/CategoriesModel.php b/administrator/components/com_categories/Model/CategoriesModel.php index 1fea193fa97ba..34e10482a19c2 100644 --- a/administrator/components/com_categories/Model/CategoriesModel.php +++ b/administrator/components/com_categories/Model/CategoriesModel.php @@ -12,7 +12,7 @@ defined('_JEXEC') or die; use Joomla\CMS\Association\AssociationServiceInterface; -use Joomla\CMS\Categories\CategoriesServiceInterface; +use Joomla\CMS\Categories\CategoryServiceInterface; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\Language\Associations; @@ -339,7 +339,7 @@ public function getAssoc() $componentObject = $this->bootComponent($component); - if ($componentObject instanceof AssociationServiceInterface && $componentObject instanceof CategoriesServiceInterface) + if ($componentObject instanceof AssociationServiceInterface && $componentObject instanceof CategoryServiceInterface) { $assoc = true; @@ -397,7 +397,7 @@ public function countItems(&$items, $extension) $component = Factory::getApplication()->bootComponent($parts[0]); - if ($component instanceof CategoriesServiceInterface) + if ($component instanceof CategoryServiceInterface) { $component->countItems($items, $section); } diff --git a/administrator/components/com_categories/Model/CategoryModel.php b/administrator/components/com_categories/Model/CategoryModel.php index 931f181c63487..90bc705b524b2 100644 --- a/administrator/components/com_categories/Model/CategoryModel.php +++ b/administrator/components/com_categories/Model/CategoryModel.php @@ -12,7 +12,7 @@ defined('_JEXEC') or die; use Joomla\CMS\Association\AssociationServiceInterface; -use Joomla\CMS\Categories\CategoriesServiceInterface; +use Joomla\CMS\Categories\CategoryServiceInterface; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Helper\TagsHelper; @@ -423,7 +423,7 @@ protected function preprocessForm(\JForm $form, $data, $group = 'content') $componentInterface = Factory::getApplication()->bootComponent($component); - if ($componentInterface instanceof CategoriesServiceInterface) + if ($componentInterface instanceof CategoryServiceInterface) { $componentInterface->prepareForm($form, $data); } @@ -1303,7 +1303,7 @@ public function getAssoc() $componentObject = $this->bootComponent($component); - if ($componentObject instanceof AssociationServiceInterface && $componentObject instanceof CategoriesServiceInterface) + if ($componentObject instanceof AssociationServiceInterface && $componentObject instanceof CategoryServiceInterface) { $assoc = true; diff --git a/administrator/components/com_content/Extension/ContentComponent.php b/administrator/components/com_content/Extension/ContentComponent.php index 370b1308ab7f3..6d45c6d753498 100644 --- a/administrator/components/com_content/Extension/ContentComponent.php +++ b/administrator/components/com_content/Extension/ContentComponent.php @@ -14,7 +14,7 @@ use Joomla\CMS\Application\SiteApplication; use Joomla\CMS\Association\AssociationServiceTrait; use Joomla\CMS\Association\AssociationServiceInterface; -use Joomla\CMS\Categories\CategoriesServiceInterface; +use Joomla\CMS\Categories\CategoryServiceInterface; use Joomla\CMS\Categories\CategoryServiceTrait; use Joomla\CMS\Extension\BootableExtensionInterface; use Joomla\CMS\Extension\MVCComponent; @@ -37,7 +37,7 @@ * @since __DEPLOY_VERSION__ */ class ContentComponent extends MVCComponent implements - BootableExtensionInterface, MVCFactoryServiceInterface, CategoriesServiceInterface, FieldsServiceInterface, + BootableExtensionInterface, MVCFactoryServiceInterface, CategoryServiceInterface, FieldsServiceInterface, AssociationServiceInterface, WorkflowServiceInterface { use CategoryServiceTrait; diff --git a/administrator/components/com_fields/Model/FieldModel.php b/administrator/components/com_fields/Model/FieldModel.php index 4dadfeec627ef..f67d21e3246bb 100644 --- a/administrator/components/com_fields/Model/FieldModel.php +++ b/administrator/components/com_fields/Model/FieldModel.php @@ -11,7 +11,7 @@ defined('_JEXEC') or die; -use Joomla\CMS\Categories\CategoriesServiceInterface; +use Joomla\CMS\Categories\CategoryServiceInterface; use Joomla\CMS\Categories\SectionNotFoundException; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; @@ -979,7 +979,7 @@ protected function preprocessForm(\JForm $form, $data, $group = 'content') // Setting the context for the category field $componentObject = $this->bootComponent($component); - if (!$componentObject instanceof CategoriesServiceInterface) + if (!$componentObject instanceof CategoryServiceInterface) { throw new SectionNotFoundException; } diff --git a/administrator/components/com_tags/Model/TagsModel.php b/administrator/components/com_tags/Model/TagsModel.php index fd275ac4add19..6e846827c3f90 100644 --- a/administrator/components/com_tags/Model/TagsModel.php +++ b/administrator/components/com_tags/Model/TagsModel.php @@ -11,7 +11,7 @@ defined('_JEXEC') or die; -use Joomla\CMS\Categories\CategoriesServiceInterface; +use Joomla\CMS\Categories\CategoryServiceInterface; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\ListModel; @@ -363,7 +363,7 @@ public function countItems(&$items, $extension) $component = Factory::getApplication()->bootComponent($parts[0]); - if ($component instanceof CategoriesServiceInterface) + if ($component instanceof CategoryServiceInterface) { $component->countTagItems($items, $extension); } diff --git a/libraries/src/Categories/Categories.php b/libraries/src/Categories/Categories.php index f4606d8925908..fd3384524beac 100644 --- a/libraries/src/Categories/Categories.php +++ b/libraries/src/Categories/Categories.php @@ -157,7 +157,7 @@ public static function getInstance($extension, $options = array()) $component = Factory::getApplication()->bootComponent($parts[0]); - if ($component instanceof CategoriesServiceInterface) + if ($component instanceof CategoryServiceInterface) { $categories = $component->getCategory($options, count($parts) > 1 ? $parts[1] : ''); } diff --git a/libraries/src/Categories/CategoriesServiceInterface.php b/libraries/src/Categories/CategoryServiceInterface.php similarity index 97% rename from libraries/src/Categories/CategoriesServiceInterface.php rename to libraries/src/Categories/CategoryServiceInterface.php index cfd21383edcfc..61f8813bb0a4d 100644 --- a/libraries/src/Categories/CategoriesServiceInterface.php +++ b/libraries/src/Categories/CategoryServiceInterface.php @@ -17,7 +17,7 @@ * * @since 4.0.0 */ -interface CategoriesServiceInterface +interface CategoryServiceInterface { /** * Returns the category service. diff --git a/libraries/src/Extension/LegacyComponent.php b/libraries/src/Extension/LegacyComponent.php index 97688e6270e1a..32627659ddb8d 100644 --- a/libraries/src/Extension/LegacyComponent.php +++ b/libraries/src/Extension/LegacyComponent.php @@ -11,7 +11,7 @@ defined('JPATH_PLATFORM') or die; use Joomla\CMS\Application\CMSApplicationInterface; -use Joomla\CMS\Categories\CategoriesServiceInterface; +use Joomla\CMS\Categories\CategoryServiceInterface; use Joomla\CMS\Categories\CategoryServiceTrait; use Joomla\CMS\Categories\CategoryInterface; use Joomla\CMS\Categories\SectionNotFoundException; @@ -29,7 +29,7 @@ * * @since 4.0.0 */ -class LegacyComponent implements ComponentInterface, MVCFactoryServiceInterface, CategoriesServiceInterface, FieldsServiceInterface +class LegacyComponent implements ComponentInterface, MVCFactoryServiceInterface, CategoryServiceInterface, FieldsServiceInterface { use CategoryServiceTrait; From c86ba159372b116cf33d02220cdac3897617c46d Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 18 Sep 2018 06:24:40 +0200 Subject: [PATCH 10/12] Rename CategoriesFactoryInterface to CategoryFactoryInterface --- administrator/components/com_banners/services/provider.php | 4 ++-- administrator/components/com_content/services/provider.php | 4 ++-- .../{CategoriesFactory.php => CategoryFactory.php} | 2 +- ...iesFactoryInterface.php => CategoryFactoryInterface.php} | 4 ++-- libraries/src/Categories/CategoryServiceTrait.php | 6 +++--- .../src/Extension/Service/Provider/CategoriesFactory.php | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) rename libraries/src/Categories/{CategoriesFactory.php => CategoryFactory.php} (95%) rename libraries/src/Categories/{CategoriesFactoryInterface.php => CategoryFactoryInterface.php} (90%) diff --git a/administrator/components/com_banners/services/provider.php b/administrator/components/com_banners/services/provider.php index 2649382f1e41b..e8b279724122d 100644 --- a/administrator/components/com_banners/services/provider.php +++ b/administrator/components/com_banners/services/provider.php @@ -9,7 +9,7 @@ defined('_JEXEC') or die; -use Joomla\CMS\Categories\CategoriesFactoryInterface; +use Joomla\CMS\Categories\CategoryFactoryInterface; use Joomla\CMS\Dispatcher\DispatcherFactoryInterface; use Joomla\CMS\Extension\ComponentInterface; use Joomla\CMS\Extension\Service\Provider\CategoriesFactory; @@ -51,7 +51,7 @@ function (Container $container) $component->setRegistry($container->get(Registry::class)); $component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class)); - $component->setCategoriesFactory($container->get(CategoriesFactoryInterface::class)); + $component->setCategoriesFactory($container->get(CategoryFactoryInterface::class)); return $component; } diff --git a/administrator/components/com_content/services/provider.php b/administrator/components/com_content/services/provider.php index 0ba9e47589fb0..8477cbe1b7ab8 100644 --- a/administrator/components/com_content/services/provider.php +++ b/administrator/components/com_content/services/provider.php @@ -10,7 +10,7 @@ defined('_JEXEC') or die; use Joomla\CMS\Association\AssociationExtensionInterface; -use Joomla\CMS\Categories\CategoriesFactoryInterface; +use Joomla\CMS\Categories\CategoryFactoryInterface; use Joomla\CMS\Dispatcher\DispatcherFactoryInterface; use Joomla\CMS\Extension\ComponentInterface; use Joomla\CMS\Extension\Service\Provider\CategoriesFactory; @@ -55,7 +55,7 @@ function (Container $container) $component->setRegistry($container->get(Registry::class)); $component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class)); - $component->setCategoriesFactory($container->get(CategoriesFactoryInterface::class)); + $component->setCategoriesFactory($container->get(CategoryFactoryInterface::class)); $component->setAssociationExtension($container->get(AssociationExtensionInterface::class)); return $component; diff --git a/libraries/src/Categories/CategoriesFactory.php b/libraries/src/Categories/CategoryFactory.php similarity index 95% rename from libraries/src/Categories/CategoriesFactory.php rename to libraries/src/Categories/CategoryFactory.php index d3ba12e58e990..9fb7c1f775d8f 100644 --- a/libraries/src/Categories/CategoriesFactory.php +++ b/libraries/src/Categories/CategoryFactory.php @@ -15,7 +15,7 @@ * * @since __DEPLOY_VERSION__ */ -class CategoriesFactory implements CategoriesFactoryInterface +class CategoryFactory implements CategoryFactoryInterface { /** * The namespace to create the categories from. diff --git a/libraries/src/Categories/CategoriesFactoryInterface.php b/libraries/src/Categories/CategoryFactoryInterface.php similarity index 90% rename from libraries/src/Categories/CategoriesFactoryInterface.php rename to libraries/src/Categories/CategoryFactoryInterface.php index 08c95766da2bd..dd8e57c20b3ee 100644 --- a/libraries/src/Categories/CategoriesFactoryInterface.php +++ b/libraries/src/Categories/CategoryFactoryInterface.php @@ -11,11 +11,11 @@ defined('_JEXEC') or die; /** - * Categories factory interface + * Category factory interface * * @since __DEPLOY_VERSION__ */ -interface CategoriesFactoryInterface +interface CategoryFactoryInterface { /** * Creates a category. diff --git a/libraries/src/Categories/CategoryServiceTrait.php b/libraries/src/Categories/CategoryServiceTrait.php index f05ba40c64034..9b944267cd645 100644 --- a/libraries/src/Categories/CategoryServiceTrait.php +++ b/libraries/src/Categories/CategoryServiceTrait.php @@ -23,7 +23,7 @@ trait CategoryServiceTrait /** * The categories factory * - * @var CategoriesFactoryInterface + * @var CategoryFactoryInterface * * @since 4.0.0 */ @@ -48,13 +48,13 @@ public function getCategory(array $options = [], $section = ''): CategoryInterfa /** * Sets the internal categories factory. * - * @param CategoriesFactoryInterface $categoriesFactory The categories factory + * @param CategoryFactoryInterface $categoriesFactory The categories factory * * @return void * * @since 4.0.0 */ - public function setCategoriesFactory(CategoriesFactoryInterface $categoriesFactory) + public function setCategoriesFactory(CategoryFactoryInterface $categoriesFactory) { $this->categoriesFactory = $categoriesFactory; } diff --git a/libraries/src/Extension/Service/Provider/CategoriesFactory.php b/libraries/src/Extension/Service/Provider/CategoriesFactory.php index 2b0a790a1d7dc..02149412dfb71 100644 --- a/libraries/src/Extension/Service/Provider/CategoriesFactory.php +++ b/libraries/src/Extension/Service/Provider/CategoriesFactory.php @@ -10,7 +10,7 @@ defined('JPATH_PLATFORM') or die; -use Joomla\CMS\Categories\CategoriesFactoryInterface; +use Joomla\CMS\Categories\CategoryFactoryInterface; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; @@ -54,10 +54,10 @@ public function __construct($namespace) public function register(Container $container) { $container->set( - CategoriesFactoryInterface::class, + CategoryFactoryInterface::class, function (Container $container) { - return new \Joomla\CMS\Categories\CategoriesFactory($this->namespace); + return new \Joomla\CMS\Categories\CategoryFactory($this->namespace); } ); } From 684acdb1685eeb51e755e00d877682425d813af5 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 18 Sep 2018 06:27:12 +0200 Subject: [PATCH 11/12] Rename setCategoriesFactory to setCategoryFactory --- .../components/com_banners/services/provider.php | 2 +- .../components/com_content/services/provider.php | 2 +- libraries/src/Categories/CategoryServiceTrait.php | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/administrator/components/com_banners/services/provider.php b/administrator/components/com_banners/services/provider.php index e8b279724122d..86002cf0b3a0d 100644 --- a/administrator/components/com_banners/services/provider.php +++ b/administrator/components/com_banners/services/provider.php @@ -51,7 +51,7 @@ function (Container $container) $component->setRegistry($container->get(Registry::class)); $component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class)); - $component->setCategoriesFactory($container->get(CategoryFactoryInterface::class)); + $component->setCategoryFactory($container->get(CategoryFactoryInterface::class)); return $component; } diff --git a/administrator/components/com_content/services/provider.php b/administrator/components/com_content/services/provider.php index 8477cbe1b7ab8..e8f0359d75978 100644 --- a/administrator/components/com_content/services/provider.php +++ b/administrator/components/com_content/services/provider.php @@ -55,7 +55,7 @@ function (Container $container) $component->setRegistry($container->get(Registry::class)); $component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class)); - $component->setCategoriesFactory($container->get(CategoryFactoryInterface::class)); + $component->setCategoryFactory($container->get(CategoryFactoryInterface::class)); $component->setAssociationExtension($container->get(AssociationExtensionInterface::class)); return $component; diff --git a/libraries/src/Categories/CategoryServiceTrait.php b/libraries/src/Categories/CategoryServiceTrait.php index 9b944267cd645..d9e4ec48a49bd 100644 --- a/libraries/src/Categories/CategoryServiceTrait.php +++ b/libraries/src/Categories/CategoryServiceTrait.php @@ -27,7 +27,7 @@ trait CategoryServiceTrait * * @since 4.0.0 */ - private $categoriesFactory; + private $categoryFactory; /** * Returns the category service. @@ -42,21 +42,21 @@ trait CategoryServiceTrait */ public function getCategory(array $options = [], $section = ''): CategoryInterface { - return $this->categoriesFactory->createCategory($options, $section); + return $this->categoryFactory->createCategory($options, $section); } /** - * Sets the internal categories factory. + * Sets the internal category factory. * - * @param CategoryFactoryInterface $categoriesFactory The categories factory + * @param CategoryFactoryInterface $categoryFactory The categories factory * * @return void * * @since 4.0.0 */ - public function setCategoriesFactory(CategoryFactoryInterface $categoriesFactory) + public function setCategoryFactory(CategoryFactoryInterface $categoryFactory) { - $this->categoriesFactory = $categoriesFactory; + $this->categoryFactory = $categoryFactory; } /** From bda3a8b280bda7d622841dfd82701d4aa86b1e28 Mon Sep 17 00:00:00 2001 From: Allon Moritz Date: Tue, 18 Sep 2018 06:33:14 +0200 Subject: [PATCH 12/12] Rename CategoriesFactory service provider to CategoryFactory --- administrator/components/com_banners/services/provider.php | 4 ++-- administrator/components/com_content/services/provider.php | 4 ++-- .../Provider/{CategoriesFactory.php => CategoryFactory.php} | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename libraries/src/Extension/Service/Provider/{CategoriesFactory.php => CategoryFactory.php} (95%) diff --git a/administrator/components/com_banners/services/provider.php b/administrator/components/com_banners/services/provider.php index 86002cf0b3a0d..ec091c0ea2401 100644 --- a/administrator/components/com_banners/services/provider.php +++ b/administrator/components/com_banners/services/provider.php @@ -12,7 +12,7 @@ use Joomla\CMS\Categories\CategoryFactoryInterface; use Joomla\CMS\Dispatcher\DispatcherFactoryInterface; use Joomla\CMS\Extension\ComponentInterface; -use Joomla\CMS\Extension\Service\Provider\CategoriesFactory; +use Joomla\CMS\Extension\Service\Provider\CategoryFactory; use Joomla\CMS\Extension\Service\Provider\DispatcherFactory; use Joomla\CMS\Extension\Service\Provider\MVCFactoryFactory; use Joomla\CMS\HTML\Registry; @@ -39,7 +39,7 @@ */ public function register(Container $container) { - $container->registerServiceProvider(new CategoriesFactory('\\Joomla\\Component\\Banners')); + $container->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Banners')); $container->registerServiceProvider(new MVCFactoryFactory('\\Joomla\\Component\\Banners')); $container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Banners')); diff --git a/administrator/components/com_content/services/provider.php b/administrator/components/com_content/services/provider.php index e8f0359d75978..820bb74b00a1f 100644 --- a/administrator/components/com_content/services/provider.php +++ b/administrator/components/com_content/services/provider.php @@ -13,7 +13,7 @@ use Joomla\CMS\Categories\CategoryFactoryInterface; use Joomla\CMS\Dispatcher\DispatcherFactoryInterface; use Joomla\CMS\Extension\ComponentInterface; -use Joomla\CMS\Extension\Service\Provider\CategoriesFactory; +use Joomla\CMS\Extension\Service\Provider\CategoryFactory; use Joomla\CMS\Extension\Service\Provider\DispatcherFactory; use Joomla\CMS\Extension\Service\Provider\MVCFactoryFactory; use Joomla\CMS\HTML\Registry; @@ -43,7 +43,7 @@ public function register(Container $container) { $container->set(AssociationExtensionInterface::class, new AssociationsHelper); - $container->registerServiceProvider(new CategoriesFactory('\\Joomla\\Component\\Banners')); + $container->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Banners')); $container->registerServiceProvider(new MVCFactoryFactory('\\Joomla\\Component\\Content')); $container->registerServiceProvider(new DispatcherFactory('\\Joomla\\Component\\Content')); diff --git a/libraries/src/Extension/Service/Provider/CategoriesFactory.php b/libraries/src/Extension/Service/Provider/CategoryFactory.php similarity index 95% rename from libraries/src/Extension/Service/Provider/CategoriesFactory.php rename to libraries/src/Extension/Service/Provider/CategoryFactory.php index 02149412dfb71..1f1359b98ee23 100644 --- a/libraries/src/Extension/Service/Provider/CategoriesFactory.php +++ b/libraries/src/Extension/Service/Provider/CategoryFactory.php @@ -19,7 +19,7 @@ * * @since __DEPLOY_VERSION__ */ -class CategoriesFactory implements ServiceProviderInterface +class CategoryFactory implements ServiceProviderInterface { /** * The namespace to create the categories from.