is example

$resolver = $context->getField()->getResolver();

        if (!$resolver) {
            return $context->getAlias();
        }

        return $resolver->join($context);
    }

    private function getReferenceColumn(Context $context, ManyToManyAssociationField $field): string
    {
        if (!$field->is(ReverseInherited::class)) {
            return self::escape($field->getReferenceField());
        }

        if (!$context->considerInheritance()) {
            return self::escape($field->getReferenceField());
        }

        /** @var ReverseInherited $flag */
        $flag = $field->getFlag(ReverseInherited::class);

        return self::escape($flag->getReversedPropertyName());
    }
continue;
            }

            if ($field instanceof ManyToOneAssociationField || $field instanceof OneToOneAssociationField) {
                $association = $this->manyToOne($row$root$field$context);

                if ($association === null && $entity instanceof PartialEntity) {
                    continue;
                }

                if ($field->is(Extension::class)) {
                    if ($association) {
                        $entity->addExtension($property$association);
                    }
                } else {
                    $entity->assign([$property => $association]);
                }

                continue;
            }

            // other association fields are not handled in entity reader query
$field->compile($container->get(DefinitionInstanceRegistry::class));

                $name = $field->getPropertyName();
                $message = sprintf('Assertion for field "%s" in entity "%s" failed', $name$entity);

                static::assertTrue($definition->getFields()->has($name)$message . ' - field not found');

                $actual = $definition->getFields()->get($name);
                static::assertInstanceOf($field::class$actual$message . ' - wrong class');

                foreach ($field->getFlags() as $flag) {
                    static::assertTrue($actual->is($flag::class)$message . ' - actual is not : ' . $flag::class);
                }

                foreach ($actual->getFlags() as $flag) {
                    static::assertTrue($field->is($flag::class)$message . ' - flag not expected: ' . $flag::class);
                }

                if ($field instanceof StorageAware) {
                    static::assertInstanceOf(StorageAware::class$actual$message);
                    static::assertSame($field->getStorageName()$actual->getStorageName()$message);
                }

                
$fields = $definition->getFields();

        $properties = [];
        $functionViolations = [];

        foreach ($fields as $field) {
            if ($field instanceof VersionField || $field instanceof ReferenceVersionField) {
                continue;
            }

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

            $key = $definition->getEntityName() . '.' . $field->getPropertyName();
            if (\in_array($key, self::IGNORE_FIELDS, true)) {
                continue;
            }

            $propertyName = $field->getPropertyName();

            $setter = 'set' . ucfirst($propertyName);
            
WriteParameterBag $parameters
    ): \Generator {
        if (!$field instanceof StringField) {
            throw DataAbstractionLayerException::invalidSerializerField(StringField::class$field);
        }

        $tmp = $data->getValue();
        if (\is_string($tmp)) {
            $tmp = trim($tmp);
        }

        if ($tmp === '' && !$field->is(AllowEmptyString::class)) {
            $data->setValue(null);
        }

        $this->validateIfNeeded($field$existence$data$parameters);

        $data->setValue($this->sanitize($this->sanitizer, $data$field$existence));

        $this->validateIfNeeded($field$existence$data$parameters);

        yield $field->getStorageName() => $data->getValue() !== null ? (string) $data->getValue() : null;
    }

    

    use IntegrationTestBehaviour;

    public function testDetectGif(): void
    {
        $type = $this->getTypeDetector()->detect(
            $this->createMediaFile(__DIR__ . '/../fixtures/logo.gif')
        );

        static::assertInstanceOf(ImageType::class$type);
        static::assertCount(1, $type->getFlags());
        static::assertTrue($type->is(ImageType::TRANSPARENT));
    }

    public function testDetectAnimatedGif(): void
    {
        $type = $this->getTypeDetector()->detect(
            $this->createMediaFile(__DIR__ . '/../fixtures/animated.gif')
        );

        static::assertInstanceOf(ImageType::class$type);
        static::assertCount(2, $type->getFlags());
        static::assertTrue($type->is(ImageType::TRANSPARENT));
        


    /** * @param array<string, mixed> $data * * @return array<string, mixed> */
    private function normalizeTranslations(TranslationsAssociationField $translationsField, array $data, WriteParameterBag $parameters, bool $hasNormalizedTranslations): array
    {
        if (!$hasNormalizedTranslations) {
            $definition = $parameters->getDefinition();
            if (!$translationsField->is(Required::class)) {
                return $data;
            }

            $parentField = $this->getParentField($definition);
            if ($parentField && isset($data[$parentField->getPropertyName()])) {
                // only normalize required translations if it's not a child                 return $data;
            }
        }

        try {
            
if ($existence->isChild() && $this->isInherited($field$parameters)) {
            return false;
        }

        if ($existence->hasEntityName()
            && $this->definitionRegistry->getByEntityName($existence->getEntityName()) instanceof EntityTranslationDefinition
            && $parameters->getCurrentWriteLanguageId() !== Defaults::LANGUAGE_SYSTEM
        ) {
            return false;
        }

        return $field->is(Required::class);
    }

    protected function isInherited(Field $field, WriteParameterBag $parameters): bool
    {
        if ($parameters->getDefinition()->isInheritanceAware()) {
            return $field->is(Inherited::class);
        }

        if (!$parameters->getDefinition() instanceof EntityTranslationDefinition) {
            return false;
        }

        
class TwigFieldVisibilityTest extends TestCase
{
    use IntegrationTestBehaviour;

    public function testInternalFieldsAreNotVisibleInTwig(): void
    {
        $definitionRegistry = $this->getContainer()->get(DefinitionInstanceRegistry::class);

        foreach ($definitionRegistry->getDefinitions() as $definition) {
            /** @var CompiledFieldCollection $internalFields */
            $internalFields = $definition->getFields()
                ->filter(fn (Field $field): bool => !$field->is(ApiAware::class));

            foreach ($internalFields as $field) {
                $this->testAccessibilityForField($definition$field->getPropertyName()$definition->getEntityClass());
                $this->testAccessibilityForField($definition$field->getPropertyName(), PartialEntity::class);
            }
        }
    }

    private function testAccessibilityForField(EntityDefinition $definition, string $propertyName, string $entityClass): void
    {
        $entity = new $entityClass();
        
continue;
            }

            if ($field instanceof AssociationField) {
                $isSingle = $field instanceof ManyToOneAssociationField || $field instanceof OneToOneAssociationField;

                $reference = $field->getReferenceDefinition();
                if ($field instanceof ManyToManyAssociationField) {
                    $reference = $field->getToManyReferenceDefinition();
                }

                if ($field->is(Extension::class)) {
                    $serialized->addExtension(
                        $propertyName,
                        [
                            'tmp' => [
                                'definition' => $reference,
                            ],
                            'data' => $isSingle ? null : [],
                        ]
                    );
                } else {
                    $serialized->addRelationship(
                        
public function getExtractPriority(): int
    {
        return 0;
    }

    public function setFlags(Flag ...$flags): self
    {
        $this->flags = [];
        foreach ($flags as $flag) {
            $this->flags[$flag::class] = $flag;
        }
        if (!$this->is(ApiAware::class)) {
            $this->addFlags(new ApiAware(AdminApiSource::class));
        }

        return $this;
    }

    public function addFlags(Flag ...$flags): self
    {
        foreach ($flags as $flag) {
            $this->flags[$flag::class] = $flag;
        }

        
$uuid = Uuid::fromStringToHex($schemaName);
        $exampleDetailPath = $path . '/' . $uuid;

        $extensions = [];
        $extensionRelationships = [];

        foreach ($definition->getFields() as $field) {
            if (!$this->shouldFieldBeIncluded($field$forSalesChannel)) {
                continue;
            }

            if ($field->is(Extension::class)) {
                $extensions[] = $field;

                continue;
            }

            if ($field->is(Required::class) && !$field instanceof VersionField && !$field instanceof ReferenceVersionField) {
                $requiredAttributes[] = $field->getPropertyName();
            }

            if ($field instanceof ManyToOneAssociationField || $field instanceof OneToOneAssociationField) {
                $relationships[] = $this->createToOneLinkage($field$exampleDetailPath);

                

        );

        return $alias;
    }

    private function buildVersionWhere(FieldResolverContext $context, OneToManyAssociationField $field): string
    {
        if (!$context->getDefinition()->isVersionAware()) {
            return '';
        }
        if (!$field->is(CascadeDelete::class)) {
            return '';
        }

        $fkVersionId = $context->getDefinition()->getEntityName() . '_version_id';

        $reference = $field->getReferenceDefinition();
        if ($reference->getFields()->getByStorageName($fkVersionId)) {
            return ' AND #root#.version_id = #alias#.' . $fkVersionId;
        }

        $fkVersionId = \substr($field->getReferenceField(), 0, -3) . '_version_id';
        

    public function update(string $entity, array $ids, Context $context): void
    {
        $ids = array_unique(array_filter($ids));
        if (empty($ids)) {
            return;
        }

        $definition = $this->registry->getByEntityName($entity);

        $inherited = $definition->getFields()->filter(fn (Field $field) => $field->is(Inherited::class) && $field instanceof AssociationField);

        $associations = $inherited->filter(fn (Field $field) => $field instanceof OneToManyAssociationField || $field instanceof ManyToManyAssociationField || $field instanceof OneToOneAssociationField);

        if ($associations->count() > 0) {
            $this->updateToManyAssociations($definition$ids$associations$context);
        }

        $associations = $inherited->filter(fn (Field $field) => $field instanceof ManyToOneAssociationField);

        if ($associations->count() > 0) {
            $this->updateToOneAssociations($definition$ids$associations$context);
        }


            // set data and payload cursor to root or extensions to simplify following if conditions             $dataCursor = $data;

            $payloadCursor = &$payload;

            if ($field instanceof VersionField || $field instanceof ReferenceVersionField) {
                continue;
            }

            if ($field->is(Extension::class)) {
                $dataCursor = $data['extensions'] ?? [];
                $payloadCursor = &$extensions;
                if (isset($dataCursor['foreignKeys'])) {
                    $fields = $definition->getFields();
                    /** * @var string $key * @var string $value */
                    foreach ($dataCursor['foreignKeys'] as $key => $value) {
                        // Clone FK extension and add it to payload                         if (\is_string($value) && Uuid::isValid($value) && $fields->has($key) && $fields->get($key) instanceof FkField) {
                            
Home | Imprint | This part of the site doesn't use cookies.