getPropertyName example

 EntityCollection {
        $hasFilters = !empty($criteria->getFilters()) || !empty($criteria->getPostFilters());
        $hasIds = !empty($criteria->getIds());

        if (!$performEmptySearch && !$hasFilters && !$hasIds) {
            return $collection;
        }

        if ($partial !== []) {
            $fields = $definition->getFields()->filter(function DField $field) use (&$partial) {
                if ($field->getFlag(PrimaryKey::class)) {
                    $partial[$field->getPropertyName()] = [];

                    return true;
                }

                return isset($partial[$field->getPropertyName()]);
            });
        }

        // always add the criteria fields to the collection, otherwise we have conflicts between criteria.fields and criteria.association logic         $fields = $this->addAssociationFieldsToCriteria($criteria$definition$fields);

        
if (empty($ids)) {
            return;
        }

        $ids = array_unique($ids);

        if ($definition instanceof MappingEntityDefinition) {
            $fkFields = $definition->getFields()->filterInstance(FkField::class);

            /** @var FkField $field */
            foreach ($fkFields as $field) {
                $foreignKeys = array_column($ids$field->getPropertyName());
                $this->update($field->getReferenceDefinition()->getEntityName()$foreignKeys$context);
            }

            return;
        }

        $fields = $definition->getFields()->filterInstance(ManyToManyIdField::class);

        if ($propertyName) {
            $fields = $fields->filter(fn (ManyToManyIdField $field) => $field->getPropertyName() === $propertyName);
        }

        
$member = clone $member;

                foreach ($member->getConstraints() as $constraint) {
                    if (\in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) {
                        $member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
                    }

                    $constraint->addImplicitGroupName($this->getDefaultGroup());
                }

                if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
                    $property = $member->getPropertyName();
                    $this->members[$property][] = $member;

                    if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
                        $this->properties[$property] = $member;
                    } elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
                        $this->getters[$property] = $member;
                    }
                } else {
                    $this->addPropertyMetadata($member);
                }
            }
        }


            $translationCode = $this->mapToTranslationCode($languageId);
            $result = iterator_to_array($entitySerializer->serialize($config$referenceDefinition$translation));

            $codedTranslations[$translationCode] = $result;
            if ($languageId === Defaults::LANGUAGE_SYSTEM) {
                $codedTranslations['DEFAULT'] = $codedTranslations[$translationCode];
            }
        }

        yield $associationField->getPropertyName() => $codedTranslations;
    }

    public function deserialize(Config $config, Field $associationField$translations)
    {
        if (!$associationField instanceof TranslationsAssociationField) {
            throw new \InvalidArgumentException('Expected *ToOneField');
        }

        $translations = \is_array($translations) ? $translations : iterator_to_array($translations);
        if (isset($translations['DEFAULT'])) {
            $translations[Defaults::LANGUAGE_SYSTEM] = $translations['DEFAULT'];
            
$fkFields = $definition->getFields()->filterInstance(FkField::class);

            if ($fkFields->count() <= 0) {
                continue;
            }

            /** @var FkField $field */
            foreach ($fkFields as $field) {
                $reference = $field->getReferenceDefinition()->getEntityName();

                $mappings[$reference] = array_merge($mappings[$reference] ?? []array_column($ids$field->getPropertyName()));
            }
        }

        return $mappings;
    }

    public function addParentResults(array $writeResults, array $parents): array
    {
        foreach ($parents as $entity => $primaryKeys) {
            $primaryKeys = array_unique($primaryKeys);
            if (!isset($writeResults[$entity])) {
                
return $alias;
    }

    private function getSelectTemplate(EntityDefinition $definition): string
    {
        $select = $definition->getFields()->fmap(function DField $field) {
            if (!$field instanceof StorageAware) {
                return null;
            }

            return '`#alias#`.' . $field->getStorageName() . ' as `#alias#.' . $field->getPropertyName() . '`';
        });

        return implode(', ', $select);
    }

    private function getTranslationQuery(
        EntityDefinition $definition,
        EntityDefinition $translationDefinition,
        string $on,
        Context $context,
        ?string $versionFieldName = null,
    ):
'v6.6.0.0',
            Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0')
        );

        $field = $context->getField();
        if (!$field instanceof SeoUrlAssociationField) {
            return $context->getAlias();
        }

        $context->getQuery()->addState(EntityDefinitionQueryHelper::HAS_TO_MANY_JOIN);

        $alias = $context->getAlias() . '.' . $field->getPropertyName();
        if ($context->getQuery()->hasState($alias)) {
            return $alias;
        }

        $context->getQuery()->addState($alias);

        $routeParamKey = 'route_' . Uuid::randomHex();
        $parameters = [
            '#source#' => EntityDefinitionQueryHelper::escape($context->getAlias()) . '.' . EntityDefinitionQueryHelper::escape($field->getLocalField()),
            '#alias#' => EntityDefinitionQueryHelper::escape($alias),
            '#reference_column#' => EntityDefinitionQueryHelper::escape($field->getReferenceField()),
            

    public function serialize(Config $config, Field $field$value): iterable
    {
        if (!$field instanceof CustomFields) {
            throw new \InvalidArgumentException('Expected field to be an instance of ' . CustomFields::class);
        }

        if (!\is_array($value)) {
            yield $field->getPropertyName() => $value;

            return;
        }

        ksort($value);

        yield $field->getPropertyName() => json_encode($value, \JSON_THROW_ON_ERROR);

        foreach ($value as $customFieldKey => $customFieldValue) {
            $customFieldValue = \is_array($customFieldValue) ? json_encode($customFieldValue, \JSON_THROW_ON_ERROR) : $customFieldValue;

            
public function testInstantiate(): void
    {
        $field = new PasswordField(
            'custom_password',
            'customPassword',
            \PASSWORD_DEFAULT,
            ['b'],
            PasswordField::FOR_ADMIN
        );

        static::assertSame('custom_password', $field->getStorageName());
        static::assertSame('customPassword', $field->getPropertyName());
        static::assertSame(\PASSWORD_DEFAULT, $field->getAlgorithm());
        static::assertSame(['b']$field->getHashOptions());
        static::assertSame('admin', $field->getFor());
    }
}
if ($flag instanceof Runtime) {
                    foreach ($flag->getDepends() as $depend) {
                        $mapped[] = implode('.', [...$accessor, ...[$depend]]);
                    }
                }

                if (!$part instanceof AssociationField) {
                    continue;
                }

                $accessor[] = $part->getPropertyName();
            }
        }

        return $mapped;
    }
}
if (isset($price['listPrice']) && $price['listPrice'] instanceof Struct) {
                $price['listPrice'] = $price['listPrice']->jsonSerialize();
            }

            $isoPrices[$currency] = $price;
            if ($currencyId === Defaults::CURRENCY) {
                $isoPrices['DEFAULT'] = $isoPrices[$currency];
            }
        }

        yield $entity->getPropertyName() => $isoPrices;
    }

    public function deserialize(Config $config, Field $field$record): ?array
    {
        $prices = [];

        if (!\is_array($record)) {
            return null;
        }

        foreach ($record as $currencyIso => $price) {
            
#[Package('core')] class ParentFieldForeignKeyConstraintMissingException extends ShopwareHttpException
{
    public function __construct(
        EntityDefinition $definition,
        Field $parentField
    ) {
        parent::__construct(
            'Foreign key property {{ propertyName }} of parent association in definition {{ definition }} expected to be an FkField got %s',
            [
                'definition' => $definition->getEntityName(),
                'propertyName' => $parentField->getPropertyName(),
                'propertyClass' => $parentField::class,
            ]
        );
    }

    public function getErrorCode(): string
    {
        return 'FRAMEWORK__PARENT_FIELD_KEY_CONSTRAINT_MISSING';
    }
}
/** @var StorageAware $field */
            $field = $fields->first();

            return Uuid::fromBytesToHex($primaryKey[$field->getStorageName()]);
        }

        foreach ($fields as $field) {
            if (!$field instanceof StorageAware) {
                continue;
            }

            $data[$field->getPropertyName()] = Uuid::fromBytesToHex($primaryKey[$field->getStorageName()]);
        }

        return $data;
    }
}
foreach ($row as $storageName => $value) {
                $field = $fields[$storageName] ?? null;

                if (!$field) {
                    $data[$storageName] = $value;

                    continue;
                }

                $value = $field->getSerializer()->decode($field$value);

                $data[$field->getPropertyName()] = $value;

                if (!$field->is(PrimaryKey::class)) {
                    continue;
                }

                $pk[$field->getPropertyName()] = $value;
            }

            $arrayKey = implode('-', $pk);

            if (\count($pk) === 1) {
                
/** * Possible paths / attribute names: * - propertyName.attribute_name -> attribute_name * - propertyName.attribute_name.foo -> attribute_name * - propertyName."attribute.name" -> attribute.name * - propertyName."attribute.name".foo -> attribute.name * * @var string $attributeName */
        $attributeName = preg_replace(
            '#^' . preg_quote($field->getPropertyName(), '#') . '\.("([^"]*)"|([^.]*)).*#',
            '$2$3',
            $accessor
        );
        $attributeField = $this->customFieldService->getCustomField($attributeName)
            ?? new JsonField($attributeName$attributeName);

        $field->setPropertyMapping([$attributeField]);

        return parent::buildAccessor($root$field$context$accessor);
    }
}
Home | Imprint | This part of the site doesn't use cookies.