Skip to content
Snippets Groups Projects
Commit d3cf7049 authored by catch's avatar catch
Browse files

Issue #3128536 by amateescu, Charlie ChX Negyesi, phenaproxima: Simplify and...

Issue #3128536 by amateescu, Charlie ChX Negyesi, phenaproxima: Simplify and speed up WorkspaceManager::isEntityTypeSupported()
parent 65031690
Branches
Tags
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!16Draft: Resolve #2081585 "History storage"
......@@ -22,16 +22,12 @@ class WorkspaceManager implements WorkspaceManagerInterface {
use StringTranslationTrait;
/**
* An array of entity type IDs that can not belong to a workspace.
*
* By default, only entity types which are revisionable and publishable can
* belong to a workspace.
* An array of which entity types are supported.
*
* @var string[]
*/
protected $blacklist = [
'workspace_association' => 'workspace_association',
'workspace' => 'workspace',
protected $supported = [
'workspace' => FALSE,
];
/**
......@@ -142,19 +138,13 @@ public function __construct(RequestStack $request_stack, EntityTypeManagerInterf
* {@inheritdoc}
*/
public function isEntityTypeSupported(EntityTypeInterface $entity_type) {
// First, check if we already determined whether this entity type is
// supported or not.
if (isset($this->blacklist[$entity_type->id()])) {
return FALSE;
}
if ($entity_type->entityClassImplements(EntityPublishedInterface::class) && $entity_type->isRevisionable()) {
return TRUE;
$entity_type_id = $entity_type->id();
if (!isset($this->supported[$entity_type_id])) {
// Only entity types which are revisionable and publishable can belong
// to a workspace.
$this->supported[$entity_type_id] = $entity_type->entityClassImplements(EntityPublishedInterface::class) && $entity_type->isRevisionable();
}
// This entity type can not belong to a workspace, add it to the blacklist.
$this->blacklist[$entity_type->id()] = $entity_type->id();
return FALSE;
return $this->supported[$entity_type_id];
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment