You are here

protected function EntityTypeInfo::getModeratedBundles in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::getModeratedBundles()
  2. 10 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::getModeratedBundles()

Returns an iterable list of entity names and bundle names under moderation.

That is, this method returns a list of bundles that have Content Moderation enabled on them.

Return value

\Generator A generator, yielding a 2 element associative array:

  • entity: The machine name of an entity type, such as "node" or "block_content".
  • bundle: The machine name of a bundle, such as "page" or "article".
1 call to EntityTypeInfo::getModeratedBundles()
EntityTypeInfo::entityExtraFieldInfo in core/modules/content_moderation/src/EntityTypeInfo.php
Gets the "extra fields" for a bundle.

File

core/modules/content_moderation/src/EntityTypeInfo.php, line 223

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\content_moderation

Code

protected function getModeratedBundles() {
  $entity_types = array_filter($this->entityTypeManager
    ->getDefinitions(), [
    $this->moderationInfo,
    'canModerateEntitiesOfEntityType',
  ]);
  foreach ($entity_types as $type_name => $type) {
    foreach ($this->bundleInfo
      ->getBundleInfo($type_name) as $bundle_id => $bundle) {
      if ($this->moderationInfo
        ->shouldModerateEntitiesOfBundle($type, $bundle_id)) {
        (yield [
          'entity' => $type_name,
          'bundle' => $bundle_id,
        ]);
      }
    }
  }
}