Skip to content

Use typed event listener instead of old deprecated OC_Hooks #515

@MorrisJobke

Description

@MorrisJobke

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions