src/Resource/EventListener/SymfonyGrantedRelationListener.php
public function onBeforeNormalization(BeforeNormalizationEvent $event): void
    {
        $resource = $event->getResource();

        if (!$resource instanceof RelatedResourceInterface) {
            return;
        }

        $relations = $resource->getRelations();

        foreach ($relations as $relation) {
            if (!$relation instanceof SymfonyGrantedRelation) {
                continue;
            }

            if (!$this->authorizationChecker->isGranted($relation->getAttribute(), $relation->getObject())) {
                $resource->removeRelation($relation);
            }
        }
    }
public function onBeforeNormalization(BeforeNormalizationEvent $event): void
    {
        $resource = $event->getResource();

        if (!$resource instanceof RelatedResourceInterface) {
            return;
        }

        $relations = $resource->getRelations();

        foreach ($relations as $relation) {
            if (!$relation instanceof SymfonyGrantedRelation) {
                continue;
            }

            if (!$this->authorizationChecker->isGranted($relation->getAttribute(), $relation->getObject())) {
                $resource->removeRelation($relation);
            }
        }
    }
public function onBeforeNormalization ( BeforeNormalizationEvent $ event ) : void { $ resource = $ event -> getResource ( ) ; if ( ! $ resource instanceof RelatedResourceInterface ) { return ; } $ relations = $ resource -> getRelations ( ) ; foreach ( $ relations as $ relation ) { if ( ! $ relation instanceof SymfonyGrantedRelation ) { continue ; } if ( ! $ this -> authorizationChecker -> isGranted ( $ relation -> getAttribute ( ) , $ relation -> getObject ( ) ) ) { $ resource -> removeRelation ( $ relation ) ; } } }
Check the grants to relations

@param BeforeNormalizationEvent $event
Check the grants to relations