diff --git a/administrator/components/com_fields/tmpl/fields/default.php b/administrator/components/com_fields/tmpl/fields/default.php index 21955fd2e5079..ad96dd24ee731 100644 --- a/administrator/components/com_fields/tmpl/fields/default.php +++ b/administrator/components/com_fields/tmpl/fields/default.php @@ -10,7 +10,6 @@ defined('_JEXEC') or die; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Multilanguage; @@ -39,11 +38,11 @@ $saveOrder = ($listOrder == 'a.ordering' && strtolower($listDirn) == 'asc'); // The category object of the component -$category = Categories::getInstance(str_replace('com_', '', $component) . '.' . $section); +$category = Factory::getApplication()->bootComponent(str_replace('com_', '', $component))->getCategory([], $section); // If there is no category for the component and section, then check the component only if (!$category) { - $category = Categories::getInstance(str_replace('com_', '', $component)); + $category = Factory::getApplication()->bootComponent(str_replace('com_', '', $component))->getCategory(); } if ($saveOrder && !empty($this->items)) { diff --git a/components/com_contact/src/Model/CategoriesModel.php b/components/com_contact/src/Model/CategoriesModel.php index a313548917ff7..338a5b85fccde 100644 --- a/components/com_contact/src/Model/CategoriesModel.php +++ b/components/com_contact/src/Model/CategoriesModel.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Contact\Site\Model; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\ListModel; @@ -125,7 +124,7 @@ public function getItems() $options = []; $options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); - $categories = Categories::getInstance('Contact', $options); + $categories = $app->bootComponent('com_contact')->getCategory($options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (\is_object($this->_parent)) { diff --git a/components/com_contact/src/Model/CategoryModel.php b/components/com_contact/src/Model/CategoryModel.php index 8e7fda5f1de79..0f342ffc46760 100644 --- a/components/com_contact/src/Model/CategoryModel.php +++ b/components/com_contact/src/Model/CategoryModel.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Contact\Site\Model; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\Helper\TagsHelper; @@ -372,7 +371,7 @@ public function getCategory() $options = []; $options['countItems'] = $params->get('show_cat_items', 1) || !$params->get('show_empty_categories', 0); - $categories = Categories::getInstance('Contact', $options); + $categories = $app->bootComponent('com_contact')->getCategory($options); $this->_item = $categories->get($this->getState('category.id', 'root')); if (\is_object($this->_item)) { diff --git a/components/com_contact/src/View/Contact/HtmlView.php b/components/com_contact/src/View/Contact/HtmlView.php index 6a977ee7ee4b9..9f5fec1ae9c6a 100644 --- a/components/com_contact/src/View/Contact/HtmlView.php +++ b/components/com_contact/src/View/Contact/HtmlView.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Contact\Site\View\Contact; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Event\Content\AfterDisplayEvent; use Joomla\CMS\Event\Content\AfterTitleEvent; use Joomla\CMS\Event\Content\BeforeDisplayEvent; @@ -442,7 +441,7 @@ protected function _prepareDocument() } $path = [['title' => $this->item->name, 'link' => '']]; - $category = Categories::getInstance('Contact')->get($this->item->catid); + $category = $app->bootComponent('com_contact')->getCategory()->get($this->item->catid); while ($category !== null && $category->id != $id && $category->id !== 'root') { $path[] = ['title' => $category->title, 'link' => RouteHelper::getCategoryRoute($category->id, $category->language)]; diff --git a/components/com_content/src/Model/CategoriesModel.php b/components/com_content/src/Model/CategoriesModel.php index a7b5403ae978b..b066b5b510cf5 100644 --- a/components/com_content/src/Model/CategoriesModel.php +++ b/components/com_content/src/Model/CategoriesModel.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Content\Site\Model; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\ListModel; @@ -127,7 +126,7 @@ public function getItems($recursive = false) $options = []; $options['countItems'] = $params->get('show_cat_num_articles_cat', 1) || !$params->get('show_empty_categories_cat', 0); $options['accessOnItems'] = !$params->get('show_noauth', 0); - $categories = Categories::getInstance('Content', $options); + $categories = $app->bootComponent('com_content')->getCategory($options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (\is_object($this->_parent)) { diff --git a/components/com_content/src/Model/CategoryModel.php b/components/com_content/src/Model/CategoryModel.php index 966de3227e111..70b4b7f3c08c9 100644 --- a/components/com_content/src/Model/CategoryModel.php +++ b/components/com_content/src/Model/CategoryModel.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Content\Site\Model; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\Language\Multilanguage; @@ -369,7 +368,7 @@ public function getCategory() $options['countItems'] = 0; } - $categories = Categories::getInstance('Content', $options); + $categories = Factory::getApplication()->bootComponent('com_content')->getCategory($options); $this->_item = $categories->get($this->getState('category.id', 'root')); // Compute selected asset permissions. diff --git a/components/com_content/src/View/Article/HtmlView.php b/components/com_content/src/View/Article/HtmlView.php index 238bd23c33f74..84f5c464619f7 100644 --- a/components/com_content/src/View/Article/HtmlView.php +++ b/components/com_content/src/View/Article/HtmlView.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Content\Site\View\Article; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Event\Content; use Joomla\CMS\Factory; use Joomla\CMS\Helper\TagsHelper; @@ -299,7 +298,7 @@ protected function _prepareDocument() } $path = [['title' => $this->item->title, 'link' => '']]; - $category = Categories::getInstance('Content')->get($this->item->catid); + $category = $app->bootComponent('com_content')->getCategory()->get($this->item->catid); while ($category !== null && $category->id != $id && $category->id !== 'root') { $path[] = ['title' => $category->title, 'link' => RouteHelper::getCategoryRoute($category->id, $category->language)]; diff --git a/components/com_content/src/View/Featured/FeedView.php b/components/com_content/src/View/Featured/FeedView.php index 29672d7ddbba9..5246e219dc207 100644 --- a/components/com_content/src/View/Featured/FeedView.php +++ b/components/com_content/src/View/Featured/FeedView.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Content\Site\View\Featured; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Document\Feed\FeedItem; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; @@ -55,7 +54,7 @@ public function display($tpl = null) // Get some data from the model $app->getInput()->set('limit', $app->get('feed_limit')); - $categories = Categories::getInstance('Content'); + $categories = $app->bootComponent('com_content')->getCategory(); /** @var FeaturedModel $model */ $model = $this->getModel(); diff --git a/components/com_newsfeeds/src/Model/CategoriesModel.php b/components/com_newsfeeds/src/Model/CategoriesModel.php index 6ad7b106849a2..dda3839c80454 100644 --- a/components/com_newsfeeds/src/Model/CategoriesModel.php +++ b/components/com_newsfeeds/src/Model/CategoriesModel.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Newsfeeds\Site\Model; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\ListModel; @@ -127,7 +126,7 @@ public function getItems() $options = []; $options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); - $categories = Categories::getInstance('Newsfeeds', $options); + $categories = $app->bootComponent('com_newsfeed')->getCategory($options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (\is_object($this->_parent)) { diff --git a/components/com_newsfeeds/src/Model/CategoryModel.php b/components/com_newsfeeds/src/Model/CategoryModel.php index 2e4ac20f0a444..b691a9b14ee58 100644 --- a/components/com_newsfeeds/src/Model/CategoryModel.php +++ b/components/com_newsfeeds/src/Model/CategoryModel.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Newsfeeds\Site\Model; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Factory; use Joomla\CMS\Helper\TagsHelper; @@ -312,7 +311,7 @@ public function getCategory() $options = []; $options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0); - $categories = Categories::getInstance('Newsfeeds', $options); + $categories = $app->bootComponent('com_newsfeed')->getCategory($options); $this->_item = $categories->get($this->getState('category.id', 'root')); if (\is_object($this->_item)) { diff --git a/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php b/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php index 3d110b3718114..f247f99542698 100644 --- a/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php +++ b/components/com_newsfeeds/src/View/Newsfeed/HtmlView.php @@ -10,7 +10,6 @@ namespace Joomla\Component\Newsfeeds\Site\View\Newsfeed; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Factory; use Joomla\CMS\Feed\FeedFactory; use Joomla\CMS\Helper\TagsHelper; @@ -261,7 +260,7 @@ protected function _prepareDocument() } $path = [['title' => $this->item->name, 'link' => '']]; - $category = Categories::getInstance('Newsfeeds')->get($this->item->catid); + $category = $app->bootComponent('com_newsfeeds')->getCategory()->get($this->item->catid); while ( isset($category->id) && $category->id > 1 diff --git a/libraries/src/Categories/CategoryNode.php b/libraries/src/Categories/CategoryNode.php index 78ac34c787057..94d925e7361f3 100644 --- a/libraries/src/Categories/CategoryNode.php +++ b/libraries/src/Categories/CategoryNode.php @@ -547,7 +547,7 @@ public function __unserialize($data) // Restore constructor from array of options. if ($this->_constructor) { - $this->_constructor = Categories::getInstance($this->_constructor['extension'], $this->_constructor); + $this->_constructor = Factory::getApplication()->bootComponent($this->_constructor['extension'])->getCategory($this->_constructor); } } } diff --git a/libraries/src/Helper/RouteHelper.php b/libraries/src/Helper/RouteHelper.php index 884286c0fda13..2bc83d3a2b335 100644 --- a/libraries/src/Helper/RouteHelper.php +++ b/libraries/src/Helper/RouteHelper.php @@ -9,7 +9,6 @@ namespace Joomla\CMS\Helper; -use Joomla\CMS\Categories\Categories; use Joomla\CMS\Categories\CategoryNode; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; @@ -92,7 +91,7 @@ public function getRoute($id, $typealias, $link = '', $language = null, $catid = } if ($catid > 1) { - $categories = Categories::getInstance($name); + $categories = Factory::getApplication()->bootComponent($name)->getCategory(); if ($categories) { $category = $categories->get((int) $catid); @@ -230,7 +229,7 @@ public static function getCategoryRoute($catid, $language = null, $extension = ' } else { $extensionName = ucfirst(substr($extension, 4)); $id = (int) $catid; - $category = Categories::getInstance($extensionName)->get($id); + $category = Factory::getApplication()->bootComponent($extensionName)->getCategory()->get($id); } if ($id < 1) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 418dc86a677e4..9772078cd12eb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1562,17 +1562,6 @@ parameters: count: 1 path: administrator/components/com_fields/tmpl/field/edit.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 2 - path: administrator/components/com_fields/tmpl/fields/default.php - - message: '#^Access to an undefined property Joomla\\Component\\Fields\\Administrator\\View\\Group\\HtmlView\:\:\$fields\.$#' identifier: property.notFound @@ -6074,28 +6063,6 @@ parameters: count: 1 path: components/com_contact/src/Controller/ContactController.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_contact/src/Model/CategoriesModel.php - - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_contact/src/Model/CategoryModel.php - - message: ''' #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Form\\Form\: @@ -6182,17 +6149,6 @@ parameters: count: 1 path: components/com_contact/src/View/Contact/HtmlView.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_contact/src/View/Contact/HtmlView.php - - message: ''' #^Call to deprecated method getErrors\(\) of class Joomla\\CMS\\MVC\\Model\\BaseModel\: @@ -6397,28 +6353,6 @@ parameters: count: 1 path: components/com_content/src/Model/ArticleModel.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_content/src/Model/CategoriesModel.php - - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_content/src/Model/CategoryModel.php - - message: ''' #^Call to deprecated method setError\(\) of class Joomla\\CMS\\MVC\\Model\\BaseModel\: @@ -6495,17 +6429,6 @@ parameters: count: 1 path: components/com_content/src/View/Article/HtmlView.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_content/src/View/Article/HtmlView.php - - message: '#^Access to an undefined property Joomla\\Component\\Content\\Site\\View\\Category\\HtmlView\:\:\$menu\.$#' identifier: property.notFound @@ -6524,17 +6447,6 @@ parameters: count: 1 path: components/com_content/src/View/Category/HtmlView.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_content/src/View/Featured/FeedView.php - - message: ''' #^Call to deprecated method getErrors\(\) of class Joomla\\CMS\\MVC\\Model\\BaseModel\: @@ -6746,28 +6658,6 @@ parameters: count: 1 path: components/com_finder/tmpl/search/default_sorting.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_newsfeeds/src/Model/CategoriesModel.php - - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_newsfeeds/src/Model/CategoryModel.php - - message: ''' #^Call to deprecated method setError\(\) of class Joomla\\CMS\\MVC\\Model\\BaseModel\: @@ -6825,17 +6715,6 @@ parameters: count: 1 path: components/com_newsfeeds/src/View/Newsfeed/HtmlView.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: components/com_newsfeeds/src/View/Newsfeed/HtmlView.php - - message: '#^Access to an undefined property Joomla\\Component\\Newsfeeds\\Site\\View\\Categories\\HtmlView\:\:\$maxLevelcat\.$#' identifier: property.notFound @@ -7996,17 +7875,6 @@ parameters: count: 1 path: libraries/src/Categories/Categories.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: libraries/src/Categories/CategoryNode.php - - message: ''' #^Call to deprecated method getUser\(\) of class Joomla\\CMS\\Factory\: @@ -10819,17 +10687,6 @@ parameters: count: 2 path: libraries/src/Helper/ModuleHelper.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class Joomla\\CMS\\Categories\\Categories\: - 4\.0 will be removed in 7\.0 - Use the ComponentInterface to get the categories - Example\: Factory\:\:getApplication\(\)\-\>bootComponent\(\$component\)\-\>getCategory\(\$options, \$section\);$# - ''' - identifier: staticMethod.deprecated - count: 2 - path: libraries/src/Helper/RouteHelper.php - - message: '#^Unsafe usage of new static\(\)\.$#' identifier: new.static