Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2][Events] Use event classes for System plugins #43637

Open
wants to merge 19 commits into
base: 5.2-dev
Choose a base branch
from
Prev Previous commit
Next Next commit
system ActionLogs
  • Loading branch information
Fedik committed Jun 9, 2024
commit 34bccb91d151ac6750e31527a31b00c52da4926d
34 changes: 18 additions & 16 deletions plugins/system/actionlogs/src/Extension/ActionLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Joomla\Plugin\System\ActionLogs\Extension;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Event\Application\AfterInitialiseEvent;
use Joomla\CMS\Event\Model;
use Joomla\CMS\Event\User;
use Joomla\CMS\Form\Form;
Expand All @@ -24,6 +25,7 @@
use Joomla\Database\Exception\ExecutionFailureException;
use Joomla\Database\ParameterType;
use Joomla\Event\DispatcherInterface;
use Joomla\Event\Priority;
use Joomla\Event\SubscriberInterface;

// phpcs:disable PSR1.Files.SideEffects
Expand All @@ -40,22 +42,6 @@ final class ActionLogs extends CMSPlugin implements SubscriberInterface
use DatabaseAwareTrait;
use UserFactoryAwareTrait;

/**
* Constructor.
*
* @param DispatcherInterface $dispatcher The dispatcher
* @param array $config An optional associative array of configuration settings
*
* @since 3.9.0
*/
public function __construct(DispatcherInterface $dispatcher, array $config)
{
parent::__construct($dispatcher, $config);

// Import actionlog plugin group so that these plugins will be triggered for events
PluginHelper::importPlugin('actionlog');
}

/**
* Returns an array of events this subscriber will listen to.
*
Expand All @@ -66,6 +52,7 @@ public function __construct(DispatcherInterface $dispatcher, array $config)
public static function getSubscribedEvents(): array
{
return [
'onAfterInitialise' => ['onAfterInitialise', Priority::ABOVE_NORMAL],
'onContentPrepareForm' => 'onContentPrepareForm',
'onContentPrepareData' => 'onContentPrepareData',
'onUserAfterSave' => 'onUserAfterSave',
Expand All @@ -74,6 +61,21 @@ public static function getSubscribedEvents(): array
];
}

/**
* After initialise listener.
*
* @param AfterInitialiseEvent $event The event instance.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onAfterInitialise(AfterInitialiseEvent $event): void
{
// Import actionlog plugin group so that these plugins will be triggered for events
PluginHelper::importPlugin('actionlog', null, true, $event->getApplication()->getDispatcher());
}

/**
* Adds additional fields to the user editing form for logs e-mail notifications
*
Expand Down