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

Use typed event listener instead of old deprecated OC_Hooks #515

Closed
MorrisJobke opened this issue Nov 10, 2020 · 0 comments · Fixed by #519
Closed

Use typed event listener instead of old deprecated OC_Hooks #515

MorrisJobke opened this issue Nov 10, 2020 · 0 comments · Fixed by #519
Assignees

Comments

@MorrisJobke
Copy link
Member

Used in https://github.com/nextcloud/circles/blob/master/lib/AppInfo/Application.php#L136

Please use:

  • OCP\Group\Events\GroupDeletedEvent for 'OC_User', 'post_deleteGroup'
  • OCP\User\Events\UserDeletedEvent for 'OC_User', 'post_deleteUser'
use OCP\Group\Events\GroupDeletedEvent;
use OCA\Circles\Listener\ GroupDeletedListener;

...
$dispatcher = $this->get(IEventDispatcher::class);
$dispatcher->addServiceListener(GroupDeletedEvent::class, GroupDeletedListener::class);

Ideally this happens in the register() method of the application. (see https://github.com/nextcloud/server/blob/bd6a6cf3bff74dc5690fe032a4203165227f01d2/apps/user_status/lib/AppInfo/Application.php#L70 for an example)

See https://github.com/nextcloud/server/blob/caff1023ea72bb2ea94130e18a2a6e2ccf819e5f/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php for example how the listener can look like.

Those hooks will be dropped in Nextcloud 21 and you can use the new system in all versions starting from Nextcloud 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants