EntityTypeInfo::getModeratedBundles

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

File

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

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\content_moderation

Code

protected function getModeratedBundles() {
  /** @var ConfigEntityTypeInterface $type */
  foreach ($this->filterNonRevisionableEntityTypes($this->entityTypeManager->getDefinitions()) as $type_name => $type) {
    $result = $this->entityTypeManager
      ->getStorage($type_name)
      ->getQuery()
      ->condition('third_party_settings.content_moderation.enabled', TRUE)
      ->execute();

    foreach ($result as $bundle_name) {
      yield ['entity' => $type->getBundleOf(), 'bundle' => $bundle_name];
    }
  }
}
doc_Drupal
2016-10-29 09:08:18
Comments
Leave a Comment

Please login to continue.