missingReverseAssociation example

if ($association instanceof ManyToManyAssociationField) {
            // fetch inverse association definition for filter             $reverses = $definition->getFields()->filter(
                fn (Field $field) => $field instanceof ManyToManyAssociationField && $association->getMappingDefinition() === $field->getMappingDefinition()
            );

            // contains now the inverse side association: category.products             /** @var ManyToManyAssociationField|null $reverse */
            $reverse = $reverses->first();
            if (!$reverse) {
                throw ApiException::missingReverseAssociation($definition->getEntityName()$parentDefinition->getEntityName());
            }

            $criteria->addFilter(
                new EqualsFilter(
                    sprintf('%s.%s.id', $definition->getEntityName()$reverse->getPropertyName()),
                    $parent['value']
                )
            );

            /** @var EntityDefinition $parentDefinition */
            if ($parentDefinition->isVersionAware()) {
                


    public function testMissingPrivileges(): void
    {
        $exception = ApiException::missingPrivileges(['read', 'write']);

        static::assertInstanceOf(MissingPrivilegeException::class$exception);
    }

    public function testMissingReverseAssociation(): void
    {
        $exception = ApiException::missingReverseAssociation('order', 'customer');

        static::assertInstanceOf(MissingReverseAssociation::class$exception);
    }

    public function testUnsupportedMediaType(): void
    {
        $exception = ApiException::unsupportedMediaType('jpeg');

        static::assertInstanceOf(UnsupportedMediaTypeHttpException::class$exception);
        static::assertSame('The Content-Type "jpeg" is unsupported.', $exception->getMessage());
    }

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