getTranslationDefinition example

 {
    }

    public function join(FieldResolverContext $context): string
    {
        $field = $context->getField();
        if (!$field instanceof TranslatedField) {
            return $context->getAlias();
        }

        $definition = $context->getDefinition();
        $translationDefinition = $definition->getTranslationDefinition();
        if (!$translationDefinition) {
            throw new \RuntimeException(sprintf('Can not detect translation definition of entity %s', $definition->getEntityName()));
        }

        $alias = $context->getAlias() . '.' . $definition->getEntityName() . '_translation';
        if ($context->getQuery()->hasState($alias)) {
            return $alias;
        }
        $context->getQuery()->addState($alias);

        $variables = [
            
$relationships[] = $this->createToOneLinkage($field$exampleDetailPath);

                continue;
            }

            if ($field instanceof AssociationField) {
                $relationships[] = $this->createToManyLinkage($field$exampleDetailPath);

                continue;
            }

            if ($field instanceof TranslatedField && $definition->getTranslationDefinition()) {
                $field = $definition->getTranslationDefinition()->getFields()->get($field->getPropertyName());
            }

            if ($field === null) {
                continue;
            }

            if ($field instanceof JsonField) {
                $attributes[] = $this->resolveJsonField($field);

                continue;
            }


    private function getTableName(string $entity): string
    {
        $definition = $this->definitionRegistry->getByEntityName($entity);

        $customFields = $definition->getField('customFields');

        $table = $definition->getEntityName();

        if ($customFields instanceof TranslatedField) {
            $table = $definition->getTranslationDefinition()?->getEntityName() ?? $table;
        }

        return $table;
    }

    /** * @param list<array{id: string, name: string, entity_name: string}> $customMediaFields * * @return array<string, array<string>> */
    private function groupFieldsPerEntity(array $customMediaFields): array
    {
if ($depthLimit < 1) {
            return '';
        }

        if (!empty($keyLookupTable[$mappedKey])) {
            return $keyLookupTable[$mappedKey];
        }

        $camelCaseMappedKey = $this->convertToCamelCase($mappedKey);

        // check direct match of translated field         $translationDefinition = $definition->getTranslationDefinition();
        if ($translationDefinition !== null) {
            $translatedFieldExactMatch = $translationDefinition->getField($camelCaseMappedKey);
            if (
                $translatedFieldExactMatch !== null
                && !($translatedFieldExactMatch instanceof FkField)
                && !($translatedFieldExactMatch instanceof IdField)
            ) {
                return 'translations.DEFAULT.' . $translatedFieldExactMatch->getPropertyName();
            }
        }

        
return false;
    }

    /** * @param array<string> $entityId * @param array<string|int, mixed> $payload * * @return array<string|int, mixed> */
    private function addTranslationToPayload(array $entityId, array $payload, EntityDefinition $definition, VersionCommitEntity $commit): array
    {
        $translationDefinition = $definition->getTranslationDefinition();

        if (!$translationDefinition) {
            return $payload;
        }
        if (!isset($entityId['id'])) {
            return $payload;
        }

        $id = $entityId['id'];

        $translations = [];

        
/** * @dataProvider provideTranslatedDefinitions */
    public function testTranslationsOnDefinitionsWithLanguageId(string $baseDefinitionClass, string $translationDefinitionClass): void
    {
        /** @var EntityDefinition $baseDefinition */
        $baseDefinition = $this->getContainer()->get($baseDefinitionClass);
        /** @var EntityTranslationDefinition $translationDefinition */
        $translationDefinition = $this->getContainer()->get($translationDefinitionClass);

        static::assertSame($translationDefinition$baseDefinition->getTranslationDefinition());
        static::assertInstanceOf(JsonField::class$baseDefinition->getFields()->get('translated'));
    }

    /** * @dataProvider provideTranslatedDefinitions */
    public function testTranslationsOnDefinitionsWithLanguageIdInOtherOrder(string $baseDefinitionClass, string $translationDefinitionClass): void
    {
        /** @var EntityDefinition $baseDefinition */
        $baseDefinition = $this->getContainer()->get($baseDefinitionClass);
        /** @var EntityTranslationDefinition $translationDefinition */
        
$fields = $source->getFields();
            $field = $fields->get($part);

            // continue if the current part is not a real field to allow access on collections             if (!$field) {
                continue;
            }

            if ($field instanceof TranslatedField && $resolveTranslated) {
                /** @var EntityDefinition $source */
                $source = $source->getTranslationDefinition();
                $fields = $source->getFields();
                $accessorFields[] = $fields->get($part);

                continue;
            }

            if ($field instanceof TranslatedField && !$resolveTranslated) {
                $accessorFields[] = $field;

                continue;
            }

            
Home | Imprint | This part of the site doesn't use cookies.