function EntityTypeInfo::addModerationToEntityType
Same name in other branches
- 9 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::addModerationToEntityType()
- 8.9.x core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::addModerationToEntityType()
- 10 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::addModerationToEntityType()
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.
Parameters
\Drupal\Core\Entity\ContentEntityTypeInterface $type: The content entity definition to modify.
Return value
\Drupal\Core\Entity\ContentEntityTypeInterface The modified content entity definition.
1 call to EntityTypeInfo::addModerationToEntityType()
- EntityTypeInfo::entityTypeAlter in core/
modules/ content_moderation/ src/ EntityTypeInfo.php - Adds Moderation configuration to appropriate entity types.
File
-
core/
modules/ content_moderation/ src/ EntityTypeInfo.php, line 168
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderationCode
protected function addModerationToEntityType(ContentEntityTypeInterface $type) {
if (!$type->hasHandlerClass('moderation')) {
$handler_class = !empty($this->moderationHandlers[$type->id()]) ? $this->moderationHandlers[$type->id()] : ModerationHandler::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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.