public function addTranslationSelect(
        string $root,
        EntityDefinition $definition,
        QueryBuilder $query,
        Context $context
    ): void {
        $translationDefinition = $definition->getTranslationDefinition();

        $fields = $translationDefinition->getFields();
        $chain = self::buildTranslationChain($root, $context, $definition->isInheritanceAware() && $context->considerInheritance());

        /** @var TranslatedField $field */
        foreach ($fields as $field) {
            if (!$field instanceof StorageAware) {
                continue;
            }

            foreach ($chain as $tableAccessor) {
                $name = $field->getPropertyName();
                $query->addSelect(
                    self::escape($tableAccessor['alias']) . '.' . self::escape($field->getStorageName()) . ' as '
                    . self::escape($tableAccessor['alias'] . '.' . $name)
                );
            }

            //check if current field is a translated field of the origin definition
            $origin = $definition->getFields()->get($field->getPropertyName());
            if ($origin instanceof TranslatedField) {
                //add selection for resolved parent-child and language inheritance
                $query->addSelect(
                    $this->getTranslationFieldSelectExpr($field, $chain) . ' as '
                    . self::escape($root . '.' . $field->getPropertyName())
                );
            }
        }
    }
public function addTranslationSelect(
        string $root,
        EntityDefinition $definition,
        QueryBuilder $query,
        Context $context
    ): void {
        $translationDefinition = $definition->getTranslationDefinition();

        $fields = $translationDefinition->getFields();
        $chain = self::buildTranslationChain($root, $context, $definition->isInheritanceAware() && $context->considerInheritance());

        /** @var TranslatedField $field */
        foreach ($fields as $field) {
            if (!$field instanceof StorageAware) {
                continue;
            }

            foreach ($chain as $tableAccessor) {
                $name = $field->getPropertyName();
                $query->addSelect(
                    self::escape($tableAccessor['alias']) . '.' . self::escape($field->getStorageName()) . ' as '
                    . self::escape($tableAccessor['alias'] . '.' . $name)
                );
            }

            //check if current field is a translated field of the origin definition
            $origin = $definition->getFields()->get($field->getPropertyName());
            if ($origin instanceof TranslatedField) {
                //add selection for resolved parent-child and language inheritance
                $query->addSelect(
                    $this->getTranslationFieldSelectExpr($field, $chain) . ' as '
                    . self::escape($root . '.' . $field->getPropertyName())
                );
            }
        }
    }
public function addTranslationSelect ( string $ root , EntityDefinition $ definition , QueryBuilder $ query , Context $ context ) : void { $ translationDefinition = $ definition -> getTranslationDefinition ( ) ; $ fields = $ translationDefinition -> getFields ( ) ; $ chain = self :: buildTranslationChain ( $ root , $ context , $ definition -> isInheritanceAware ( ) && $ context -> considerInheritance ( ) ) ; /** @var TranslatedField $field */ foreach ( $ fields as $ field ) { if ( ! $ field instanceof StorageAware ) { continue ; } foreach ( $ chain as $ tableAccessor ) { $ name = $ field -> getPropertyName ( ) ; $ query -> addSelect ( self :: escape ( $ tableAccessor [ 'alias' ] ) . '.' . self :: escape ( $ field -> getStorageName ( ) ) . ' as ' . self :: escape ( $ tableAccessor [ 'alias' ] . '.' . $ name ) ) ; } //check if current field is a translated field of the origin definition $ origin = $ definition -> getFields ( ) -> get ( $ field -> getPropertyName ( ) ) ; if ( $ origin instanceof TranslatedField ) { //add selection for resolved parent-child and language inheritance $ query -> addSelect ( $ this -> getTranslationFieldSelectExpr ( $ field , $ chain ) . ' as ' . self :: escape ( $ root . '.' . $ field -> getPropertyName ( ) ) ) ; } } }
Adds the full translation select part to the provided sql query.
Considers the parent-child inheritance and provided context language inheritance.
The raw parameter allows to skip the parent-child inheritance.
Adds the full translation select part to the provided sql query . Considers the parent - child inheritance and provided context language inheritance . The raw parameter allows to skip the parent - child inheritance .