<?php
namespace App\Controller\Api\V1\Profile;
use App\Entity\Profile\Profile;
use App\Responders\EntityResponder;
use App\Service\AuthenticationService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class Get
{
/**
* @var AuthenticationService
*/
private $authenticationService;
public function __construct(AuthenticationService $authenticationService)
{
$this->authenticationService = $authenticationService;
}
/**
* @Route(path="/v1/profile/{id}", methods={"GET"})
*
* @SWG\Get(
* tags={"Profile"}
* )
*
* @SWG\Response(
* response=200,
* description="Success response"
* )
*
*
*
* @param Profile $profile
* @param EntityResponder $entityResponder
* @return JsonResponse
*///@IsGranted("PROFILE_ACCESS", subject="profile")
public function __invoke(Profile $profile, EntityResponder $entityResponder)
{
$groups = ['profile:index', 'profile:show'];
if ($this->authenticationService->userIsMmpzServiceAdmin()) {
$groups[] = 'service-admin-access';
}
return $entityResponder($profile, $groups);
}
}