diff --git a/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php b/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php index 158e669716f..b0e5c690826 100644 --- a/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php +++ b/src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php @@ -13,7 +13,6 @@ // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects -use Joomla\CMS\Application\SiteApplication; use Joomla\CMS\Association\AssociationServiceInterface; use Joomla\CMS\Association\AssociationServiceTrait; use Joomla\CMS\Categories\CategoryServiceInterface; @@ -78,7 +77,7 @@ public function boot(ContainerInterface $container) ) ); - $this->getRegistry()->register('weblinkicon', new Icon($container->get(SiteApplication::class))); + $this->getRegistry()->register('weblinkicon', new Icon()); } /** diff --git a/src/administrator/components/com_weblinks/src/Service/HTML/Icon.php b/src/administrator/components/com_weblinks/src/Service/HTML/Icon.php index 08589a4173c..9f70d2837a1 100644 --- a/src/administrator/components/com_weblinks/src/Service/HTML/Icon.php +++ b/src/administrator/components/com_weblinks/src/Service/HTML/Icon.php @@ -36,7 +36,7 @@ class Icon /** * The application * - * @var CMSApplication + * @var ?CMSApplication * * @since 4.0.0 */ @@ -45,15 +45,27 @@ class Icon /** * Service constructor * - * @param CMSApplication $application The application + * @param ?CMSApplication $application The application, the current application is used when not given * * @since 4.0.0 */ - public function __construct(CMSApplication $application) + public function __construct(?CMSApplication $application = null) { $this->application = $application; } + /** + * Get the application, falls back to the current application + * + * @return CMSApplication + * + * @since __DEPLOY_VERSION__ + */ + private function getApplication(): CMSApplication + { + return $this->application ?? Factory::getApplication(); + } + /** * Method to generate a link to the create item page for the given category * @@ -99,8 +111,7 @@ public function create($category, $params, $attribs = []) */ public function edit($weblink, $params, $attribs = [], $legacy = false) { - $user = $this->application->getIdentity(); - $uri = Uri::getInstance(); + $uri = Uri::getInstance(); // Ignore if in a popup window. if ($params && $params->get('popup')) { return ''; @@ -116,7 +127,7 @@ public function edit($weblink, $params, $attribs = [], $legacy = false) property_exists($weblink, 'checked_out') && property_exists($weblink, 'checked_out_time') && $weblink->checked_out - && $weblink->checked_out !== $this->application->getIdentity()->id + && $weblink->checked_out !== $this->getApplication()->getIdentity()->id ) { $checkoutUser = $this->getUserFactory()->loadUserById($weblink->checked_out); $date = HTMLHelper::_('date', $weblink->checked_out_time);