denyAccessUnlessGranted('ROLE_USER'); $data = \json_decode($request->getContent(), true); if (null === $data) { throw new BadRequestHttpException(sprintf('Could not decode json received, or data invalid: %s, %s', json_last_error(), json_last_error_msg())); } if (!\array_key_exists('object', $data)) { throw new BadRequestHttpException('the object key is not present'); } if (!\array_key_exists('class', $data)) { throw new BadRequestHttpException('the class key is not present'); } if (null !== $data['object']) { $object = $this->denormalizer->denormalize($data['object'], $data['class'], 'json'); } else { $object = null; } $roles = []; foreach (($data['roles'] ?? []) as $role) { $roles[$role] = $this->security->isGranted($role, $object); } return $this->json( ['roles' => $roles], 200, [], ); } }