FieldResolverContext example

$resolver = $field->getResolver();
            if ($resolver === null) {
                continue;
            }

            if ($field instanceof AssociationField) {
                $path[] = $field->getPropertyName();
            }

            $currentPath = implode('.', $path);
            $resolverContext = new FieldResolverContext($currentPath$alias$field$definition$rootDefinition$query$context$criteriaPart);

            $alias = $this->callResolver($resolverContext);

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

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

            

    }

    public function testVersionConstraintWithVersionedReferenceToVersionedEntity(): void
    {
        // Document itself is not versioned, but has a versioned reference on the versioned order         $documentDefinition = $this->definitionInstanceRegistry->get(DocumentDefinition::class);
        $orderDefinition = $this->definitionInstanceRegistry->get(OrderDefinition::class);
        $documentAssociationField = $documentDefinition->getField('order');

        static::assertNotNull($documentAssociationField);
        $resolverContext = new FieldResolverContext(
            '',
            'document',
            $documentAssociationField,
            $documentDefinition,
            $orderDefinition,
            $this->queryBuilder,
            $this->context,
            null,
        );

        $this->resolver->join($resolverContext);

        
$this->assertProductNames([
            ['parent-original-en-GB', $enContext],
            ['parent-original-de-DE', $deContext],
            ['parent-original-en-GB', $enVersionContext],
            ['parent-original-de-DE', $deVersionContext],
        ]$ids->get('child'));
    }

    public function testFieldResolverThrowsOnNotTranslatedEntities(): void
    {
        $resolver = $this->getContainer()->get(TranslationFieldResolver::class);
        $context = new FieldResolverContext(
            '',
            '',
            new TranslatedField(''),
            $this->getContainer()->get(ProductManufacturerTranslationDefinition::class),
            $this->getContainer()->get(ProductManufacturerTranslationDefinition::class),
            new QueryBuilder($this->getContainer()->get(Connection::class)),
            Context::createDefaultContext(),
            null
        );

        $this->expectException(\RuntimeException::class);
        
$resolver = $field->getResolver();
            if ($resolver === null) {
                continue;
            }

            if ($field instanceof AssociationField) {
                $path[] = $field->getPropertyName();
            }

            $currentPath = implode('.', $path);
            $resolverContext = new FieldResolverContext($currentPath$alias$field$definition$rootDefinition$query$context$criteriaPart);

            $alias = $this->callResolver($resolverContext);

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

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

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