buildVersionWhere example

'#reference_column#' => $this->getReferenceColumn($context$field),
        ];

        $context->getQuery()->leftJoin(
            EntityDefinitionQueryHelper::escape($mappingAlias),
            EntityDefinitionQueryHelper::escape($field->getToManyReferenceDefinition()->getEntityName()),
            EntityDefinitionQueryHelper::escape($alias),
            str_replace(
                array_keys($parameters),
                array_values($parameters),
                '#mapping#.#source_column# = #alias#.#reference_column# '
                . $this->buildVersionWhere($field->getToManyReferenceDefinition()$field)
            )
        );

        return $alias;
    }

    private function buildMappingVersionWhere(ManyToManyAssociationField $association, EntityDefinition $definition): string
    {
        if (!$definition->isVersionAware()) {
            return '';
        }
        
$source = $this->getSourceColumn($context$field);

        $referenceColumn = $this->getReferenceColumn($context$field);

        $parameters = [
            '#source#' => $source,
            '#alias#' => EntityDefinitionQueryHelper::escape($alias),
            '#reference_column#' => $referenceColumn,
            '#root#' => EntityDefinitionQueryHelper::escape($context->getAlias()),
        ];

        $versionWhere = $this->buildVersionWhere($context$field);

        $context->getQuery()->leftJoin(
            EntityDefinitionQueryHelper::escape($context->getAlias()),
            EntityDefinitionQueryHelper::escape($field->getReferenceDefinition()->getEntityName()),
            EntityDefinitionQueryHelper::escape($alias),
            str_replace(
                array_keys($parameters),
                array_values($parameters),
                '#source# = #alias#.#reference_column#' . $versionWhere
            )
        );

        
'#alias#' => self::escape($alias),
        ];

        $query->leftJoin(
            self::escape($definition->getEntityName()),
            '(' . $nested->getSQL() . ')',
            self::escape($alias),
            str_replace(
                array_keys($parameters),
                array_values($parameters),
                '#root#.#source_column# = #alias#.`id`'
                . $this->buildVersionWhere($definition$first)
            )
        );

        foreach ($nested->getParameters() as $key => $value) {
            $type = $nested->getParameterType($key);
            $query->setParameter($key$value$type);
        }
    }

    private function parseFilter(JoinGroup $group, EntityDefinition $definition, QueryBuilder $query, Context $context, string $alias): void
    {
        
'#alias#' => EntityDefinitionQueryHelper::escape($alias),
            '#reference_column#' => $referenceColumn,
        ];

        $context->getQuery()->leftJoin(
            EntityDefinitionQueryHelper::escape($context->getAlias()),
            EntityDefinitionQueryHelper::escape($table),
            EntityDefinitionQueryHelper::escape($alias),
            str_replace(
                array_keys($parameters),
                array_values($parameters),
                '#source# = #alias#.#reference_column#' . $this->buildVersionWhere($context$field),
            ),
        );

        return $alias;
    }

    protected function getSourceColumn(EntityDefinition $definition, AssociationField $field, string $root, Context $context): string
    {
        if (!$field instanceof ManyToOneAssociationField && !$field instanceof OneToOneAssociationField) {
            throw new \RuntimeException('Expected field of type ManyToOneAssociationField or OneToOneAssociationField');
        }

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