You are here

public function ModerationInformation::isBundleForModeratableEntity in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 src/ModerationInformation.php \Drupal\workbench_moderation\ModerationInformation::isBundleForModeratableEntity()

Determines if config entity is a bundle for entities that may be moderated.

This is the same check as exists in selectRevisionableEntityTypes(), but that one cannot use the entity manager due to recursion and this one doesn't have the entity list otherwise so must use the entity manager. The alternative would be to call getDefinitions() on entityTypeManager and use that in a sub-call, but that would be unnecessarily memory intensive.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check.

Return value

bool TRUE if we want to add a Moderation operation to this entity, FALSE otherwise.

Overrides ModerationInformationInterface::isBundleForModeratableEntity

File

src/ModerationInformation.php, line 113

Class

ModerationInformation
General service for moderation-related questions about Entity API.

Namespace

Drupal\workbench_moderation

Code

public function isBundleForModeratableEntity(EntityInterface $entity) {
  $type = $entity
    ->getEntityType();
  return $type instanceof ConfigEntityTypeInterface && ($bundle_of = $type
    ->get('bundle_of')) && $this->entityTypeManager
    ->getDefinition($bundle_of)
    ->isRevisionable() && $this->currentUser
    ->hasPermission('administer moderation states');
}