joomla-extensions / weblinks

This repo is meant to hold the decoupled com_weblinks component and related code.
GNU General Public License v2.0
45 stars 88 forks source link

Convert System - Weblinks plugin to service provider #517

Closed joomdonation closed 1 year ago

joomdonation commented 1 year ago

Pull Request for Issue # .

Summary of Changes

Covert System - Weblinks plugin to modern plugin structure.

Testing Instructions

Expected result

Works

Actual result

Works

Documentation Changes Required

Fedik commented 1 year ago

I would suggest to do not convert to SubscriberInterface here, untill it have a proper event object. But it will be not that easy.

joomdonation commented 1 year ago

@Fedik As the $event object is an instance of Joomla\Event\Event, I think the code is fine as it is. Later, if we have a proper event object (which should be a child class of Joomla\Event\Event), the current code will still work well.

Fedik commented 1 year ago

The issue, that then it should not use return, but use "set result". Events does not really support return value. As I remember, currently in Core we do not have a solid solution for it.

The listener could be like:

public function onGetStats(GetStatsEvent $event)
{
...
  $extension = $event['extension'];
...
  $event['subject']->addStats($stats);
}
joomdonation commented 1 year ago

We can use the same solution with ResultAware or $app->triggerEvent. I will have to test it but I think the last commit should address that concern.

Fedik commented 1 year ago

yeah, maybe can be like that