protected function getParentEntitySettings(EntityInterface $embed, ListAttribute $parent_attribute) { $parent_entity_settings = []; $view_scope = $this->getViewScope(); $view_config_service = $this->getServiceLocator()->getViewConfigService(); $parent_entity = $embed->getParent(); if ($parent_entity) { // settings specified on parent entity $entity_renderer_config = $view_config_service->getRendererConfig($view_scope, $this->getOutputFormat(), $parent_entity); $all_fields_options = $entity_renderer_config->get('__all_fields', new ArrayConfig([])); $specific_fields_options = $entity_renderer_config->get('__fields_options', new ArrayConfig([])); $parent_field_options = $specific_fields_options->get('field_' . $parent_attribute->getName(), new ArrayConfig([])); $parent_entity_settings = array_replace_recursive($all_fields_options->toArray(), $parent_field_options->toArray()); } return new ArrayConfig($parent_entity_settings); }
protected function buildValidationRules() { $rules = parent::buildValidationRules(); $options = $this->getOptions(); $rule = new AssetListRule('valid-asset-list', $options); $rules->push($rule); return $rules; }
protected function buildValidationRules() { $rules = parent::buildValidationRules(); $options = $this->getOptions(); $rules->push(new ListRule('valid-list', $options)); $rules->push(new BooleanListRule('valid-boolean-list', $options)); return $rules; }
public function __construct($name, EntityTypeInterface $type, array $options = [], AttributeInterface $parent = null) { parent::__construct($name, $type, $options, $parent); $this->entity_type_map = $this->createEmbeddedTypeMap(); }
public static function filterEmptyPayloadComingFromEmbedTemplates(ListAttribute $attribute, array $payload) { $filtered_payload = []; foreach ($payload as $embedded_entity_data) { if (isset($embedded_entity_data['__template'])) { $embed_values = []; $embed_type = $attribute->getEmbeddedTypeByPrefix($embedded_entity_data['@type']); foreach ($embed_type->getAttributes() as $embedded_attribute) { $attr_name = $embedded_attribute->getName(); if (isset($embedded_entity_data[$attr_name]) && !empty($embedded_entity_data[$attr_name])) { $embed_values[$attr_name] = $embedded_entity_data[$attr_name]; } } if (!empty($embed_values)) { $filtered_payload[] = $embedded_entity_data; } } else { $filtered_payload[] = $embedded_entity_data; } } return $filtered_payload; }