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 Actionlog plugins #43639

Open
wants to merge 6 commits into
base: 5.2-dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
actionlog
  • Loading branch information
Fedik committed Jun 9, 2024
commit 099244b03d6b2491fd94af5b290c3f3f5ed59abb
38 changes: 24 additions & 14 deletions plugins/actionlog/joomla/src/Extension/Joomla.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Event\Application;
use Joomla\CMS\Event\Cache;
use Joomla\CMS\Event\Checkin;
use Joomla\CMS\Event\Extension;
use Joomla\CMS\Event\Model;
use Joomla\CMS\Event\User;
use Joomla\CMS\MVC\Factory\MVCFactoryServiceInterface;
use Joomla\CMS\Table\Table;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Actionlogs\Administrator\Helper\ActionlogsHelper;
use Joomla\Component\Actionlogs\Administrator\Plugin\ActionLogPlugin;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Database\Exception\ExecutionFailureException;
use Joomla\Event\DispatcherInterface;
use Joomla\Event\Event;
use Joomla\Event\SubscriberInterface;
use Joomla\Utilities\ArrayHelper;

Expand Down Expand Up @@ -986,14 +988,15 @@ public function onUserAfterRemind(User\AfterRemindEvent $event): void
*
* Method is called after user request to check-in items.
*
* @param array $table Holds the table name.
* @param Checkin\AfterCheckinEvent $event The event instance.
*
* @return void
*
* @since 3.9.3
*/
public function onAfterCheckin($table)
public function onAfterCheckin(Checkin\AfterCheckinEvent $event): void
{
$table = $event->getTableName();
$context = 'com_checkin';
$user = $this->getApplication()->getIdentity();

Expand Down Expand Up @@ -1025,7 +1028,7 @@ public function onAfterCheckin($table)
*
* @since 3.9.4
*/
public function onAfterLogPurge()
public function onAfterLogPurge(): void
{
$context = $this->getApplication()->getInput()->get('option');
$user = $this->getApplication()->getIdentity();
Expand All @@ -1051,7 +1054,7 @@ public function onAfterLogPurge()
*
* @since 3.9.4
*/
public function onAfterLogExport()
public function onAfterLogExport(): void
{
$context = $this->getApplication()->getInput()->get('option');
$user = $this->getApplication()->getIdentity();
Expand All @@ -1073,14 +1076,15 @@ public function onAfterLogExport()
*
* Method is called after user request to clean cached items.
*
* @param string $group Holds the group name.
* @param Cache\AfterPurgeEvent $event The event instance.
*
* @return void
*
* @since 3.9.4
*/
public function onAfterPurge($group = 'all')
public function onAfterPurge(Cache\AfterPurgeEvent $event): void
{
$group = $event->getGroup() ?: 'all';
$context = $this->getApplication()->getInput()->get('option');
$user = $this->getApplication()->getIdentity();

Expand Down Expand Up @@ -1111,7 +1115,7 @@ public function onAfterPurge($group = 'all')
*
* @since 4.0.0
*/
public function onAfterDispatch()
public function onAfterDispatch(): void
{
if (!$this->getApplication()->isClient('api')) {
return;
Expand Down Expand Up @@ -1149,14 +1153,19 @@ public function onAfterDispatch()
*
* Method is called after user update the CMS.
*
* @param string $oldVersion The Joomla version before the update
* @param Event $event The event instance.
*
* @return void
*
* @since 3.9.21
*
* @TODO: Update to use a real event class
*/
public function onJoomlaAfterUpdate($oldVersion = null)
public function onJoomlaAfterUpdate(Event $event): void
{
$arguments = array_values($event->getArguments());
$oldVersion = $arguments[0] ?? '';

$context = $this->getApplication()->getInput()->get('option');
$user = $this->getApplication()->getIdentity();

Expand Down Expand Up @@ -1268,16 +1277,17 @@ public function onUserAfterResetComplete($user)
/**
* Method is called before user data is stored in the database
*
* @param array $user Holds the old user data.
* @param boolean $isNew True if a new user is stored.
* @param array $data Holds the new user data.
* @param User\BeforeSaveEvent $event The event instance.
*
* @return void
*
* @since 5.0.0
*/
public function onUserBeforeSave($user, $isnew, $new): void
public function onUserBeforeSave(User\BeforeSaveEvent $event): void
{
$user = $event->getUser();
$new = $event->getData();

$session = $this->getApplication()->getSession();
$session->set('block', null);

Expand Down