public function resolveAccessor(
        string $fieldName,
        EntityDefinition $definition,
        string $root,
        QueryBuilder $query,
        Context $context
    ): void {
        $fieldName = str_replace('extensions.', '', $fieldName);

        //example: `product.manufacturer.media.name`
        $original = $fieldName;
        $prefix = $root . '.';

        if (strpos($fieldName, $prefix) === 0) {
            $fieldName = substr($fieldName, \strlen($prefix));
        }

        $fields = $definition->getFields();

        if (!$fields->has($fieldName)) {
            $associationKey = explode('.', $fieldName);
            $fieldName = array_shift($associationKey);
        }

        if (!$fields->has($fieldName)) {
            return;
        }

        /** @var AssociationField|null $field */
        $field = $fields->get($fieldName);

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

        $resolver = $field->getResolver();

        if ($resolver !== null) {
            $resolver->resolve($definition, $root, $field, $query, $context, $this);
        }

        if (!$field instanceof AssociationField) {
            return;
        }

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

        $this->resolveAccessor(
            $original,
            $referenceDefinition,
            $root . '.' . $field->getPropertyName(),
            $query,
            $context
        );
    }
public function resolveAccessor(
        string $fieldName,
        EntityDefinition $definition,
        string $root,
        QueryBuilder $query,
        Context $context
    ): void {
        $fieldName = str_replace('extensions.', '', $fieldName);

        //example: `product.manufacturer.media.name`
        $original = $fieldName;
        $prefix = $root . '.';

        if (strpos($fieldName, $prefix) === 0) {
            $fieldName = substr($fieldName, \strlen($prefix));
        }

        $fields = $definition->getFields();

        if (!$fields->has($fieldName)) {
            $associationKey = explode('.', $fieldName);
            $fieldName = array_shift($associationKey);
        }

        if (!$fields->has($fieldName)) {
            return;
        }

        /** @var AssociationField|null $field */
        $field = $fields->get($fieldName);

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

        $resolver = $field->getResolver();

        if ($resolver !== null) {
            $resolver->resolve($definition, $root, $field, $query, $context, $this);
        }

        if (!$field instanceof AssociationField) {
            return;
        }

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

        $this->resolveAccessor(
            $original,
            $referenceDefinition,
            $root . '.' . $field->getPropertyName(),
            $query,
            $context
        );
    }
public function resolveAccessor ( string $ fieldName , EntityDefinition $ definition , string $ root , QueryBuilder $ query , Context $ context ) : void { $ fieldName = str_replace ( 'extensions.' , '' , $ fieldName ) ; //example: `product.manufacturer.media.name` $ original = $ fieldName ; $ prefix = $ root . '.' ; if ( strpos ( $ fieldName , $ prefix ) === 0 ) { $ fieldName = substr ( $ fieldName , \ strlen ( $ prefix ) ) ; } $ fields = $ definition -> getFields ( ) ; if ( ! $ fields -> has ( $ fieldName ) ) { $ associationKey = explode ( '.' , $ fieldName ) ; $ fieldName = array_shift ( $ associationKey ) ; } if ( ! $ fields -> has ( $ fieldName ) ) { return ; } /** @var AssociationField|null $field */ $ field = $ fields -> get ( $ fieldName ) ; if ( $ field === null ) { return ; } $ resolver = $ field -> getResolver ( ) ; if ( $ resolver !== null ) { $ resolver -> resolve ( $ definition , $ root , $ field , $ query , $ context , $ this ) ; } if ( ! $ field instanceof AssociationField ) { return ; } $ referenceDefinition = $ field -> getReferenceDefinition ( ) ; if ( $ field instanceof ManyToManyAssociationField ) { $ referenceDefinition = $ field -> getToManyReferenceDefinition ( ) ; } $ this -> resolveAccessor ( $ original , $ referenceDefinition , $ root . '.' . $ field -> getPropertyName ( ) , $ query , $ context ) ; }
Used for dynamic sql joins. In case that the given fieldName is unknown or event nested with multiple association
roots, the function can resolve each association part of the field name, even if one part of the fieldName contains a translation or event inherited data field.
Used for dynamic sql joins . In case that the given fieldName is unknown or event nested with multiple association roots the function can resolve each association part of the field name even if one part of the fieldName contains a translation or event inherited data field .