function EntityTypeInfo::entityTypeAlter
Same name in this branch
- 10 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityTypeAlter()
Same name in other branches
- 9 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityTypeAlter()
- 9 core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityTypeAlter()
- 8.9.x core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityTypeAlter()
- 8.9.x core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityTypeAlter()
- 11.x core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityTypeAlter()
- 11.x core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityTypeAlter()
- 11.x core/modules/workspaces/src/Hook/EntityTypeInfo.php \Drupal\workspaces\Hook\EntityTypeInfo::entityTypeAlter()
Adds Workspace configuration to appropriate entity types.
Parameters
\Drupal\Core\Entity\EntityTypeInterface[] $entity_types: An array of entity types.
See also
File
-
core/
modules/ workspaces/ src/ EntityTypeInfo.php, line 87
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\workspacesCode
public function entityTypeAlter(array &$entity_types) {
foreach ($entity_types as $entity_type) {
if (!$this->workspaceInfo
->isEntityTypeSupported($entity_type)) {
continue;
}
// Workspace-support status has been declared in the "build" phase, now we
// can use that information and add additional configuration in the
// "alter" phase.
$entity_type->addConstraint('EntityWorkspaceConflict');
$entity_type->setRevisionMetadataKey('workspace', 'workspace');
// Non-default workspaces display the active revision on the canonical
// route of an entity, so the latest version route is no longer needed.
$link_templates = $entity_type->get('links');
unset($link_templates['latest-version']);
$entity_type->set('links', $link_templates);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.