src/Controller/Api/V1/Profile/Get.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Api\V1\Profile;
  3. use App\Entity\Profile\Profile;
  4. use App\Responders\EntityResponder;
  5. use App\Service\AuthenticationService;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  7. use Swagger\Annotations as SWG;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class Get
  11. {
  12.     /**
  13.      * @var AuthenticationService
  14.      */
  15.     private $authenticationService;
  16.     public function __construct(AuthenticationService $authenticationService)
  17.     {
  18.         $this->authenticationService $authenticationService;
  19.     }
  20.     /**
  21.      * @Route(path="/v1/profile/{id}", methods={"GET"})
  22.      *
  23.      * @SWG\Get(
  24.      *   tags={"Profile"}
  25.      * )
  26.      *
  27.      * @SWG\Response(
  28.      *     response=200,
  29.      *     description="Success response"
  30.      * )
  31.      *
  32.      *
  33.      *
  34.      * @param Profile $profile
  35.      * @param EntityResponder $entityResponder
  36.      * @return JsonResponse
  37.      *///@IsGranted("PROFILE_ACCESS", subject="profile")
  38.     public function __invoke(Profile $profileEntityResponder $entityResponder)
  39.     {
  40.         $groups = ['profile:index''profile:show'];
  41.         if ($this->authenticationService->userIsMmpzServiceAdmin()) {
  42.             $groups[] = 'service-admin-access';
  43.         }
  44.         return $entityResponder($profile$groups);
  45.     }
  46. }