You are here

protected function ConfigEntityRevisionsEntityTypeInfo::addModerationToEntityTypes in Config Entity Revisions 8.2

Modifies an entity definition to include moderation support.

This primarily just means an extra handler. A Generic one is provided, but individual entity types can provide their own as appropriate.

Note that this function name ends in 's' to avoid having an incompatible declaration with the one in content moderation.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $type: The content entity definition to modify.

Return value

\Drupal\Core\Entity\EntityTypeInterface The modified content entity definition.

1 call to ConfigEntityRevisionsEntityTypeInfo::addModerationToEntityTypes()
ConfigEntityRevisionsEntityTypeInfo::entityTypeAlter in src/ConfigEntityRevisionsEntityTypeInfo.php
Adds Moderation configuration to appropriate entity types.

File

src/ConfigEntityRevisionsEntityTypeInfo.php, line 57

Class

ConfigEntityRevisionsEntityTypeInfo
Class ConfigEntityRevisionsEntityTypeInfo.

Namespace

Drupal\config_entity_revisions

Code

protected function addModerationToEntityTypes(EntityTypeInterface $type) {
  if (!$type
    ->hasHandlerClass('moderation')) {
    $handler_class = !empty($this->moderationHandlers[$type
      ->id()]) ? $this->moderationHandlers[$type
      ->id()] : ConfigEntityRevisionsModerationHandler::class;
    $type
      ->setHandlerClass('moderation', $handler_class);
  }
  if (!$type
    ->hasLinkTemplate('latest-version') && $type
    ->hasLinkTemplate('canonical')) {
    $type
      ->setLinkTemplate('latest-version', $type
      ->getLinkTemplate('canonical') . '/latest');
  }
  $providers = $type
    ->getRouteProviderClasses() ?: [];
  if (empty($providers['moderation'])) {
    $providers['moderation'] = EntityModerationRouteProvider::class;
    $type
      ->setHandlerClass('route_provider', $providers);
  }
  return $type;
}