function EntityTypeInfo::getModeratedBundles

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()
  3. 11.x 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,
                ]);
            }
        }
    }
}

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