function EntityTypeInfo::entityTypeBuild
Same name in other branches
- 9 core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityTypeBuild()
- 8.9.x core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityTypeBuild()
- 11.x core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityTypeBuild()
- 11.x core/modules/workspaces/src/Hook/EntityTypeInfo.php \Drupal\workspaces\Hook\EntityTypeInfo::entityTypeBuild()
Adds workspace support info to eligible entity types.
Parameters
\Drupal\Core\Entity\EntityTypeInterface[] $entity_types: An associative array of all entity type definitions, keyed by the entity type name. Passed by reference.
See also
File
-
core/
modules/ workspaces/ src/ EntityTypeInfo.php, line 48
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\workspacesCode
public function entityTypeBuild(array &$entity_types) {
foreach ($entity_types as $entity_type) {
if ($entity_type->hasHandlerClass('workspace')) {
continue;
}
// Revisionable and publishable entity types are always supported.
if ($entity_type->entityClassImplements(EntityPublishedInterface::class) && $entity_type->isRevisionable()) {
$entity_type->setHandlerClass('workspace', DefaultWorkspaceHandler::class);
// Support for custom blocks has to be determined on a per-entity
// basis.
if ($entity_type->id() === 'block_content') {
$entity_type->setHandlerClass('workspace', BlockContentWorkspaceHandler::class);
}
}
// The 'file' entity type is allowed to perform CRUD operations inside a
// workspace without being tracked.
if ($entity_type->id() === 'file') {
$entity_type->setHandlerClass('workspace', IgnoredWorkspaceHandler::class);
}
// Internal entity types are allowed to perform CRUD operations inside a
// workspace.
if ($entity_type->isInternal()) {
$entity_type->setHandlerClass('workspace', IgnoredWorkspaceHandler::class);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.