- Issue created by @amateescu
- Status changed to Needs review
over 1 year ago 9:31am 18 March 2024 - last update
over 1 year ago 182 pass - πΊπΈUnited States danflanagan8 St. Louis, US
Interested in this...
I was testing this patch out and it didn't seem to change anything for me. I thought it was maybe because the Paragraph entity type has a php attribute (or whatever) now in addition to the annotation that the patch modified. More likely it's that I have wse installed and that module alters entity type info for several common entity types:
/** * Implements hook_entity_type_build(). */ function wse_entity_type_build(array &$entity_types) { // Allow CRUD operations for various entity types in workspaces. $ignored_entity_types = [ 'crop', 'events_logging', 'file', 'paragraph', 'variant', ]; foreach ($ignored_entity_types as $entity_type_id) { if (isset($entity_types[$entity_type_id])) { $entity_types[$entity_type_id]->setHandlerClass('workspace', IgnoredWorkspaceHandler::class); } } }
This still doesn't all the Create part of CRUD though, right? I can only create a new entity in a workspace if it `isEntityTypeSupported` which has to pass this check:
$supported = !is_a($entity_type->getHandlerClass('workspace'), IgnoredWorkspaceHandler::class, TRUE);
So RUD operations seems to be more accurate.
- π·π΄Romania amateescu
You can create paragraph entities in a workspace if you have WSE installed or this patch, but they're not tracked by that workspace :) The CRUD part mostly means "allow any operation for this entity type but don't track it".
- πΊπΈUnited States danflanagan8 St. Louis, US
@amateescu, thanks for the quick reply!
The error I'm seeing is "Paragraphs can only be created in the default workspace.", which is coming from the
WseEntityReferenceSupportedNewEntitiesConstraint
, though the core one would flag this as well.The key checks are...
From core:
if ($value->hasNewEntity() && !$this->workspaceInfo->isEntityTypeSupported($target_entity_type)) { $this->context->addViolation($constraint->message, ['%collection_label' => $target_entity_type->getCollectionLabel()]); }
From WSE:
if ($value->hasNewEntity() && !$target_entity_type->isInternal() && !\Drupal::service('workspaces.information')->isEntityTypeSupported($target_entity_type)) { $this->context->addViolation($constraint->message, ['%collection_label' => $target_entity_type->getCollectionLabel()]); }
I guess the situation is that I could create a Paragraph in a Workspace if I somehow do it without using the Paragraphs field widget. So technically, CRUD is allowed, but in practice creating a Paragraph is going to throw this constraint validation.
On my client's project, I could do a field_info_alter to remove this constraint from paragraph fields. But is this in fact a bug in the validation constraint?
- πΊπΈUnited States danflanagan8 St. Louis, US
I decided to open up an issue against wse so that I could put in an MR to adjust the constraint. β¨ Modify constraint to allow new ignored entities Active