/** * Ensure a property is defined in the data definition and raise an exception if it is unknown. * * @param string $property The property name to check. * * @param PropertiesDefinitionInterface $propertyDefinitions The property definitions. * * @return void * * @throws DcGeneralInvalidArgumentException When the property is not registered in the definition. */ protected function ensurePropertyExists($property, $propertyDefinitions) { if (!$propertyDefinitions->hasProperty($property)) { throw new DcGeneralInvalidArgumentException(sprintf('Property %s is mentioned in palette but not defined in propertyDefinition.', $property)); } }
/** * Build the property information for a certain property from the data container array. * * @param PropertiesDefinitionInterface $definition The property collection definition. * * @param string $propName The name of the property. * * @param IInputScreen $inputScreen The input screen instance. * * @return void */ protected function buildPropertyFromDca(PropertiesDefinitionInterface $definition, $propName, IInputScreen $inputScreen) { $property = $inputScreen->getProperty($propName); $propInfo = $property['info']; $metaModel = $this->getMetaModel(); $attribute = $metaModel->getAttribute($propName); if (!$attribute) { return; } $isTranslated = $metaModel->isTranslated() && $attribute instanceof ITranslated; if ($definition->hasProperty($propName)) { $property = $definition->getProperty($propName); } else { $property = new DefaultProperty($propName); $definition->addProperty($property); } if (!$property->getLabel() && isset($propInfo['label'])) { $lang = $propInfo['label']; if (is_array($lang)) { $label = reset($lang); $description = next($lang); $property->setDescription($description); } else { $label = $lang; } $property->setLabel($label); } if (!$property->getDescription() && isset($propInfo['description'])) { $property->setDescription($propInfo['description']); } if (!$property->getDefaultValue() && isset($propInfo['default'])) { $property->setDefaultValue($propInfo['default']); } if (isset($propInfo['exclude'])) { $property->setExcluded($propInfo['exclude']); } if (isset($propInfo['search'])) { $property->setSearchable($propInfo['search']); } if (isset($propInfo['filter'])) { $property->setFilterable($propInfo['filter']); } if (!$property->getWidgetType() && isset($propInfo['inputType'])) { $property->setWidgetType($propInfo['inputType']); } if (!$property->getOptions() && isset($propInfo['options'])) { $property->setOptions($propInfo['options']); } if (!$property->getExplanation() && isset($propInfo['explanation'])) { $property->setExplanation($propInfo['explanation']); } if (isset($propInfo['eval'])) { $extra = $propInfo['eval']; if ($isTranslated) { $extra['tl_class'] = 'translat-attr' . (!empty($extra['tl_class']) ? ' ' . $extra['tl_class'] : ''); } $property->setExtra(array_merge((array) $property->getExtra(), $extra)); } }