MetaModels\DcGeneral\Dca\Builder\Builder::buildPropertyFromDca PHP Метод

buildPropertyFromDca() защищенный Метод

Build the property information for a certain property from the data container array.
protected buildPropertyFromDca ( ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\PropertiesDefinitionInterface $definition, string $propName, MetaModels\BackendIntegration\InputScreen\IInputScreen $inputScreen ) : void
$definition ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\PropertiesDefinitionInterface The property collection definition.
$propName string The name of the property.
$inputScreen MetaModels\BackendIntegration\InputScreen\IInputScreen The input screen instance.
Результат 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 || !$propInfo) {
            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));
        }
    }