public function FlagForListSubscriber::flagListsEntityFlagged in Flag Lists 8
Same name and namespace in other branches
- 4.0.x src/EventSubscriber/FlagForListSubscriber.php \Drupal\flag_lists\EventSubscriber\FlagForListSubscriber::flagListsEntityFlagged()
This is called whenever the flag.entity_flagged event is dispatched.
Parameters
Symfony\Component\EventDispatcher\Event $flag_event: The response event.
File
- src/EventSubscriber/ FlagForListSubscriber.php, line 38 
Class
- FlagForListSubscriber
- Class FlagForListSubscriber.
Namespace
Drupal\flag_lists\EventSubscriberCode
public function flagListsEntityFlagged(Event $flag_event) {
  $flagId = $flag_event
    ->getFlagging()
    ->getFlagId();
  foreach (\Drupal::service('flaglists')
    ->getAllFlagForList() as $collection) {
    if ($collection
      ->getBaseFlag() == $flagId) {
      $this
        ->messenger()
        ->addMessage(t('Entity added to the %flaglist list.', [
        '%flaglist' => $flagId,
      ]));
    }
  }
}