You are here

function flag_flag_delete in Flag 8.4

Implements hook_ENTITY_TYPE_delete().

File

./flag.module, line 641
The Flag module.

Code

function flag_flag_delete(FlagInterface $flag) {

  // Do not delete actions when config is progress of synchronization.
  if ($flag
    ->isSyncing()) {
    return;
  }
  $actions = Action::loadMultiple([
    'flag_action.' . $flag
      ->id() . '_flag',
    'flag_action.' . $flag
      ->id() . '_unflag',
  ]);

  // Remove the flag/unflag actions for this flag and entity combination.
  foreach ($actions as $action) {
    $action
      ->delete();
  }
}