function ContentModerationHooks::workflowInsert

Implements hook_ENTITY_TYPE_insert().

Attributes

#[Hook('workflow_insert')]

File

core/modules/content_moderation/src/Hook/ContentModerationHooks.php, line 337

Class

ContentModerationHooks
Hook implementations for content_moderation.

Namespace

Drupal\content_moderation\Hook

Code

public function workflowInsert(WorkflowInterface $entity) : void {
  // Clear bundle cache so workflow gets added or removed from the bundle
  // information.
  \Drupal::service('entity_type.bundle.info')->clearCachedBundles();
  // Clear field cache so extra field is added or removed.
  \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
  // Clear the views data cache so the extra field is available in views.
  if (\Drupal::moduleHandler()->moduleExists('views')) {
    Views::viewsData()->clear();
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.