You are here

function flag_lists_actions_flagging_collection_presave in Flag Lists 4.0.x

Implements hook_ENTITY_presave().

File

modules/flag_lists_actions/flag_lists_actions.module, line 69
Contains flag_lists_actions.module.

Code

function flag_lists_actions_flagging_collection_presave(EntityInterface $entity) {
  $flag = $entity
    ->getRelatedFlag();
  if ($flag
    ->isSyncing()) {

    // Do not create actions when config is progress of synchronization.
    return;
  }

  // The action plugin cache needs to detect the new flag.

  /** @var \Drupal\Core\Action\ActionManager $action_manager */
  $action_manager = \Drupal::service('plugin.manager.action');
  $action_manager
    ->clearCachedDefinitions();
  FlagListsActionsController::createActions($entity);
}