You are here

public function FlagForListSubscriber::flagListsEntityUnflagged in Flag Lists 8

Same name and namespace in other branches
  1. 4.0.x src/EventSubscriber/FlagForListSubscriber.php \Drupal\flag_lists\EventSubscriber\FlagForListSubscriber::flagListsEntityUnflagged()

This is called whenever the flag.entity_unflagged event is dispatched.

Parameters

Symfony\Component\EventDispatcher\Event $flag_events: The response events.

File

src/EventSubscriber/FlagForListSubscriber.php, line 57

Class

FlagForListSubscriber
Class FlagForListSubscriber.

Namespace

Drupal\flag_lists\EventSubscriber

Code

public function flagListsEntityUnflagged(Event $flag_events) {
  foreach ($flag_events
    ->getFlaggings() as $flagging) {
    $flagId = $flagging
      ->getFlagId();
    foreach (\Drupal::service('flaglists')
      ->getAllFlagForList() as $collection) {
      if ($collection
        ->getBaseFlag() == $flagId) {
        $this
          ->messenger()
          ->addMessage(t('Entity removed from the %flaglist list.', [
          '%flaglist' => $flagId,
        ]));
      }
    }
  }
}