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);
            }
        }
    }