Skip to content

Commit

Permalink
Migrate from old hooks to symfony events
Browse files Browse the repository at this point in the history
Migrate from old hooks to symfony events

Signed-off-by: Sujith H <[email protected]>
  • Loading branch information
sharidas committed Feb 1, 2018
1 parent 76539af commit e7d043f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
7 changes: 4 additions & 3 deletions lib/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'));
}

/**
Expand Down

0 comments on commit e7d043f

Please sign in to comment.