Closed (fixed)
Project:
Custom Elements
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Nov 2025 at 16:43 UTC
Updated:
24 Mar 2026 at 10:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
fagoComment #4
fagosee MR comments
Comment #10
arthur_lorenz commentedReworked the MR based on @fago's review feedback:
1. Moved to main module — formatter is now in custom_elements, not custom_elements_extra_formatters.
2. More generic, but scoped — renamed to BundleTypeCeFieldFormatter (plugin ID entity_bundle_type). Instead of being
restricted to fields named "type", it's now applicable to any entity reference field whose target type is a bundle
config entity (node_type, paragraphs_type, etc.) via isApplicable() + getBundleOf().
3. No entity loading when not needed — reads target_id directly when skip_access_check is enabled.
4. Configurable access check — added skip_access_check boolean setting (default FALSE). When enabled, outputs the
bundle ID without loading the entity or checking access.
Kernel test covers: attribute output, slot output, access check enforcement, and applicability checks.
Comment #11
arthur_lorenz commentedAttached patch file
Comment #12
fagothx! this looks pretty good already. I added some rather minor remarks, but let's make sure we re-use existing helpers. see MR!
Comment #13
arthur_lorenz commentedThx, addressed review feedback in the latest push:
1. Use trait helpers for output: Added CustomElementsFieldFormatterUtilsTrait and replaced manual slot/attribute/flatten logic with $this->setMultipleValue().
2. Defensive isApplicable: Added early return for empty $target_type, and simplified to use $field_definition->getSetting('target_type') instead of going through getFieldStorageDefinition() (since FieldConfigBase::getSetting() already falls back to storage settings).
3. Consolidated tests: Merged 5 test methods into 3 to reduce PHPUnit setup overhead — slot/attribute checks are now combined in testOutputWithSkipAccessCheck, and applicability checks in testIsApplicable.
Comment #14
fagothx, this seems all good now! let's do some more testing before we merge though!
Comment #16
fagoworks well! Merged.