diff --git a/src/plugins/finder/weblinks/services/provider.php b/src/plugins/finder/weblinks/services/provider.php index 01ba3dd5d6..1ed02cb74c 100644 --- a/src/plugins/finder/weblinks/services/provider.php +++ b/src/plugins/finder/weblinks/services/provider.php @@ -13,6 +13,7 @@ // phpcs:enable PSR1.Files.SideEffects use Joomla\CMS\Extension\PluginInterface; +use Joomla\CMS\Factory; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Database\DatabaseInterface; use Joomla\DI\Container; @@ -37,6 +38,7 @@ function (Container $container) { $plugin = new Weblinks( (array) PluginHelper::getPlugin('finder', 'weblinks') ); + $plugin->setApplication(Factory::getApplication()); $plugin->setDatabase($container->get(DatabaseInterface::class)); return $plugin; diff --git a/src/plugins/finder/weblinks/src/Extension/Weblinks.php b/src/plugins/finder/weblinks/src/Extension/Weblinks.php index eb6c8372aa..5689c481dd 100644 --- a/src/plugins/finder/weblinks/src/Extension/Weblinks.php +++ b/src/plugins/finder/weblinks/src/Extension/Weblinks.php @@ -17,7 +17,6 @@ use Joomla\CMS\Categories\Categories; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Event\Finder as FinderEvent; -use Joomla\CMS\Factory; use Joomla\Component\Finder\Administrator\Indexer\Adapter; use Joomla\Component\Finder\Administrator\Indexer\Helper; use Joomla\Component\Finder\Administrator\Indexer\Indexer; @@ -300,7 +299,7 @@ protected function index(Result $item) $item->addTaxonomy('Type', 'Web Link'); // Add the category taxonomy data. - $component = Factory::getApplication()->bootComponent('com_weblinks'); + $component = $this->getApplication()->bootComponent('com_weblinks'); $categories = $component->getCategory(['published' => false, 'access' => false]); $category = $categories->get($item->catid); diff --git a/src/plugins/system/weblinks/services/provider.php b/src/plugins/system/weblinks/services/provider.php index 47dbdb23c9..b9566ab61a 100644 --- a/src/plugins/system/weblinks/services/provider.php +++ b/src/plugins/system/weblinks/services/provider.php @@ -13,6 +13,7 @@ // phpcs:enable PSR1.Files.SideEffects use Joomla\CMS\Extension\PluginInterface; +use Joomla\CMS\Factory; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Database\DatabaseInterface; use Joomla\DI\Container; @@ -38,11 +39,14 @@ function (Container $container) { $dispatcher = $container->get(DispatcherInterface::class); $database = $container->get(DatabaseInterface::class); - return new Weblinks( + $plugin = new Weblinks( $dispatcher, (array) PluginHelper::getPlugin('system', 'weblinks'), $database ); + $plugin->setApplication(Factory::getApplication()); + + return $plugin; } ); } diff --git a/src/plugins/system/weblinks/src/Extension/Weblinks.php b/src/plugins/system/weblinks/src/Extension/Weblinks.php index e009491848..bbc5c3eb31 100644 --- a/src/plugins/system/weblinks/src/Extension/Weblinks.php +++ b/src/plugins/system/weblinks/src/Extension/Weblinks.php @@ -11,7 +11,6 @@ namespace Joomla\Plugin\System\Weblinks\Extension; use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\Database\DatabaseAwareTrait; @@ -128,14 +127,14 @@ public function onGetStats(Event $event) */ public function onAfterRender() { - $input = Factory::getApplication()->getInput(); + $input = $this->getApplication()->getInput(); $option = $input->get('option'); $view = $input->get('view'); $layout = $input->get('layout'); $component = $input->get('component'); $extension = $input->get('extension'); - $body = Factory::getApplication()->getBody(); - $lang = Factory::getLanguage()->getTag(); + $body = $this->getApplication()->getBody(); + $lang = $this->getApplication()->getLanguage()->getTag(); $modified = false; // 1. Handle com_categories for weblinks @@ -215,7 +214,7 @@ public function onAfterRender() // Set the modified body back if changes were made if ($modified) { - Factory::getApplication()->setBody($body); + $this->getApplication()->setBody($body); } return true;