|
@@ -2,11 +2,13 @@
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
+use App\Entity\Profile;
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
use App\Form\UserEditProfilType;
|
|
|
use App\Form\ProfileType;
|
|
|
use App\Repository\ProfileRepository;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
+use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
@@ -51,4 +53,29 @@ class ProfilController extends AbstractController
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ #[Route("/changeview", name: "user_changeview")]
|
|
|
+ public function changeView(EntityManagerInterface $em): JsonResponse
|
|
|
+ {
|
|
|
+ /** @var \App\Entity\User $user */
|
|
|
+ $user = $this->getUser();
|
|
|
+ $profile = $user->getProfile();
|
|
|
+ if ($profile->getView() == Profile::$VIEW['liste']) {
|
|
|
+ $profile->setView(Profile::$VIEW['vignette']);
|
|
|
+ } else {
|
|
|
+ $profile->setView(Profile::$VIEW['liste']);
|
|
|
+ }
|
|
|
+ $em->flush();
|
|
|
+
|
|
|
+ return $this->json($profile->getView());
|
|
|
+ }
|
|
|
+
|
|
|
+ #[Route("/getview", name: "user_getview")]
|
|
|
+ public function getView(): JsonResponse
|
|
|
+ {
|
|
|
+ /** @var \App\Entity\User $user */
|
|
|
+ $user = $this->getUser();
|
|
|
+
|
|
|
+ return $this->json($user->getProfile()->getView());
|
|
|
+ }
|
|
|
+
|
|
|
}
|