You are here

protected function ConfigEntityRevisionsEntityTypeInfo::getModeratedBundles in Config Entity Revisions 8.2

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".

File

src/ConfigEntityRevisionsEntityTypeInfo.php, line 223

Class

ConfigEntityRevisionsEntityTypeInfo
Class ConfigEntityRevisionsEntityTypeInfo.

Namespace

Drupal\config_entity_revisions

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,
        ]);
      }
    }
  }
}