By socketwench on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x-4.x
Issue links:
Description:
In Flag 7.x-3.x, hook_flag_reset() was invoked whenever a flag was reset. (Resetting a flag is an action which removes all the flaggings made with that flag, by all users.)
In Flag 8.x-4.x, hook_flag_reset() has been removed. A FLAG_RESET event is now triggered when a flag is resent. The FlagResetEvent class is passed to your event subscriber containing both the flag, and the number of flaggings to delete.
Note that when a flag is reset, this does not result in ENTITY_UNFLAGGED events, only a single reset event.
7.x
<?php
function your_module_flag_reset($flag) {
// respond to flag reset.
}
?>8.x
Instead of implementing a hook, create an event subscriber class. Your method must accept a FlagResetEvent object as a single parameter.
<?php
class MyFlagEventSubscriber implements EventSubscriberInterface {
public function respondToReset(FlagResetEvent $event) {
//respond to flag reset.
}
public function getSubscribedEvents() {
return [FlagEvents::FLAG_RESET][] = array('respondToReset', 0);
}
}
?>Impacts:
Module developers