Skip to content
Snippets Groups Projects

Introduce tags and context_requirements

Files
20
@@ -168,13 +168,6 @@ abstract class FieldPropertiesSourceDeriverBase extends DeriverBase implements C
public function getDerivativeDefinitionsForField(array $derivative_for_this_field, FieldStorageDefinitionInterface $field_storage_definition) {
// Generate one plugin for each field property,
// compatible only for the corresponding bundles.
$ui_patterns_component_per_item_context = new ContextDefinition('string');
$ui_patterns_component_per_item_context
->setRequired(TRUE)
->setLabel("ui_patterns_entity_field_granularity")
->setDefaultValue("item")
// This line is fundamental, and does what we want to achieve.
->addConstraint("AllowedValues", ["item"]);
foreach ($field_storage_definition->getPropertyDefinitions() as $property_id => $property_definition) {
// Skip entity reference
// Description could have been more precise,
@@ -192,10 +185,9 @@ abstract class FieldPropertiesSourceDeriverBase extends DeriverBase implements C
// @todo ,
"description" => $description,
"prop_types" => $this->getPropTypesDeriver($property_definition),
"context_requirements" => ["field_granularity:item"],
]
);
$derivative['context_definitions'] = array_merge(
$derivative['context_definitions'], ["ui_patterns_entity_field_granularity" => $ui_patterns_component_per_item_context]);
$derivative['id'] = implode(PluginBase::DERIVATIVE_SEPARATOR, [
$derivative['id'],
$property_id,
Loading