From e7d043f137c5c95700a2030c1c813ff6744c7624 Mon Sep 17 00:00:00 2001 From: Sujith H Date: Thu, 1 Feb 2018 14:32:16 +0530 Subject: [PATCH] Migrate from old hooks to symfony events Migrate from old hooks to symfony events Signed-off-by: Sujith H --- lib/AppInfo/Application.php | 4 +++- lib/Hooks.php | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 8707a8537..a8b0b8757 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -32,6 +32,7 @@ use OCA\Activity\DataHelper; use OCA\Activity\GroupHelper; use OCA\Activity\FilesHooks; +use OCA\Activity\Hooks; use OCA\Activity\MailQueueHandler; use OCA\Activity\Navigation; use OCA\Activity\Parameter\Factory; @@ -287,7 +288,8 @@ public function registerHooksAndEvents() { $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', ['OCA\Activity\FilesHooksStatic', 'onLoadFilesAppScripts']); - Util::connectHook('OC_User', 'post_deleteUser', 'OCA\Activity\Hooks', 'deleteUser'); + $activityHook = new Hooks(); + $eventDispatcher->addListener('user.afterdelete', [$activityHook, 'deleteUser']); $this->registerFilesActivity(); } diff --git a/lib/Hooks.php b/lib/Hooks.php index f822e57bf..d9158dfc9 100755 --- a/lib/Hooks.php +++ b/lib/Hooks.php @@ -23,6 +23,7 @@ use OCA\Activity\AppInfo\Application; use OCP\IDBConnection; +use Symfony\Component\EventDispatcher\GenericEvent; /** * Handles the stream and mail queue of a user when he is being deleted @@ -33,10 +34,10 @@ class Hooks { * * @param array $params The hook params */ - static public function deleteUser($params) { + static public function deleteUser(GenericEvent $params) { $connection = \OC::$server->getDatabaseConnection(); - self::deleteUserStream($params['uid']); - self::deleteUserMailQueue($connection, $params['uid']); + self::deleteUserStream($params->getArgument('uid')); + self::deleteUserMailQueue($connection, $params->getArgument('uid')); } /**