fetch user preferences via API (#2905)
This commit is contained in:
@@ -13,6 +13,7 @@ namespace App\API;
|
||||
|
||||
use App\Configuration\SystemConfiguration;
|
||||
use App\Entity\User;
|
||||
use App\Event\PrepareUserEvent;
|
||||
use App\Form\API\UserApiCreateForm;
|
||||
use App\Form\API\UserApiEditForm;
|
||||
use App\Repository\Query\UserQuery;
|
||||
@@ -26,6 +27,7 @@ use HandcraftedInTheAlps\RestRoutingBundle\Controller\Annotations\RouteResource;
|
||||
use Nelmio\ApiDocBundle\Annotation\Security as ApiSecurity;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Swagger\Annotations as SWG;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
@@ -137,7 +139,7 @@ final class UserController extends BaseApiController
|
||||
* @ApiSecurity(name="apiUser")
|
||||
* @ApiSecurity(name="apiToken")
|
||||
*/
|
||||
public function getAction(int $id): Response
|
||||
public function getAction(int $id, EventDispatcherInterface $dispatcher): Response
|
||||
{
|
||||
$user = $this->repository->find($id);
|
||||
|
||||
@@ -149,6 +151,10 @@ final class UserController extends BaseApiController
|
||||
throw new AccessDeniedHttpException('You are not allowed to view this profile');
|
||||
}
|
||||
|
||||
// we need to prepare the user preferences, which is done via an EventSubscriber
|
||||
$event = new PrepareUserEvent($user);
|
||||
$dispatcher->dispatch($event);
|
||||
|
||||
$view = new View($user, 200);
|
||||
$view->getContext()->setGroups(self::GROUPS_ENTITY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user