Skip to content

Commit e7d043f

Browse files
committed
Migrate from old hooks to symfony events
Migrate from old hooks to symfony events Signed-off-by: Sujith H <[email protected]>
1 parent 76539af commit e7d043f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/AppInfo/Application.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use OCA\Activity\DataHelper;
3333
use OCA\Activity\GroupHelper;
3434
use OCA\Activity\FilesHooks;
35+
use OCA\Activity\Hooks;
3536
use OCA\Activity\MailQueueHandler;
3637
use OCA\Activity\Navigation;
3738
use OCA\Activity\Parameter\Factory;
@@ -287,7 +288,8 @@ public function registerHooksAndEvents() {
287288
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
288289
$eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', ['OCA\Activity\FilesHooksStatic', 'onLoadFilesAppScripts']);
289290

290-
Util::connectHook('OC_User', 'post_deleteUser', 'OCA\Activity\Hooks', 'deleteUser');
291+
$activityHook = new Hooks();
292+
$eventDispatcher->addListener('user.afterdelete', [$activityHook, 'deleteUser']);
291293

292294
$this->registerFilesActivity();
293295
}

lib/Hooks.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use OCA\Activity\AppInfo\Application;
2525
use OCP\IDBConnection;
26+
use Symfony\Component\EventDispatcher\GenericEvent;
2627

2728
/**
2829
* Handles the stream and mail queue of a user when he is being deleted
@@ -33,10 +34,10 @@ class Hooks {
3334
*
3435
* @param array $params The hook params
3536
*/
36-
static public function deleteUser($params) {
37+
static public function deleteUser(GenericEvent $params) {
3738
$connection = \OC::$server->getDatabaseConnection();
38-
self::deleteUserStream($params['uid']);
39-
self::deleteUserMailQueue($connection, $params['uid']);
39+
self::deleteUserStream($params->getArgument('uid'));
40+
self::deleteUserMailQueue($connection, $params->getArgument('uid'));
4041
}
4142

4243
/**

0 commit comments

Comments
 (0)