diff options
Diffstat (limited to 'src/controller')
-rw-r--r-- | src/controller/ArticleController.php | 6 | ||||
-rw-r--r-- | src/controller/CalendarController.php | 3 | ||||
-rw-r--r-- | src/controller/UserController.php | 10 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/controller/ArticleController.php b/src/controller/ArticleController.php index a982d8c..71bfdc3 100644 --- a/src/controller/ArticleController.php +++ b/src/controller/ArticleController.php | |||
@@ -101,7 +101,11 @@ class ArticleController | |||
101 | static public function deleteArticle(EntityManager $entityManager, array $json): Response | 101 | static public function deleteArticle(EntityManager $entityManager, array $json): Response |
102 | { | 102 | { |
103 | $director = new Director($entityManager); | 103 | $director = new Director($entityManager); |
104 | $director->makeArticleNode($json['id'], true); | 104 | if(!$director->makeArticleNode($json['id'], true)){ |
105 | return new Response( | ||
106 | '{"success": false, "message": "Erreur: pas d\'article à supprimer"}', | ||
107 | Response::HTTP_INTERNAL_SERVER_ERROR); // 500 | ||
108 | } | ||
105 | $article = $director->getArticleNode(); | 109 | $article = $director->getArticleNode(); |
106 | $section = $director->getNode(); | 110 | $section = $director->getNode(); |
107 | 111 | ||
diff --git a/src/controller/CalendarController.php b/src/controller/CalendarController.php index cc37d0f..b60ff11 100644 --- a/src/controller/CalendarController.php +++ b/src/controller/CalendarController.php | |||
@@ -52,6 +52,7 @@ class CalendarController | |||
52 | $entityManager->flush(); | 52 | $entityManager->flush(); |
53 | 53 | ||
54 | echo json_encode(['success' => true, 'id' => $event->getId()]); | 54 | echo json_encode(['success' => true, 'id' => $event->getId()]); |
55 | die; | ||
55 | } | 56 | } |
56 | static public function updateEvent(array $json, EntityManager $entityManager):void | 57 | static public function updateEvent(array $json, EntityManager $entityManager):void |
57 | { | 58 | { |
@@ -67,6 +68,7 @@ class CalendarController | |||
67 | $entityManager->flush(); | 68 | $entityManager->flush(); |
68 | 69 | ||
69 | echo json_encode(['success' => true]); | 70 | echo json_encode(['success' => true]); |
71 | die; | ||
70 | } | 72 | } |
71 | static public function removeEvent(array $json, EntityManager $entityManager):void | 73 | static public function removeEvent(array $json, EntityManager $entityManager):void |
72 | { | 74 | { |
@@ -75,5 +77,6 @@ class CalendarController | |||
75 | $entityManager->flush(); | 77 | $entityManager->flush(); |
76 | 78 | ||
77 | echo json_encode(['success' => true]); | 79 | echo json_encode(['success' => true]); |
80 | die; | ||
78 | } | 81 | } |
79 | } \ No newline at end of file | 82 | } \ No newline at end of file |
diff --git a/src/controller/UserController.php b/src/controller/UserController.php index 1acb4d5..a35b09e 100644 --- a/src/controller/UserController.php +++ b/src/controller/UserController.php | |||
@@ -22,14 +22,14 @@ class UserController | |||
22 | // account | 22 | // account |
23 | static public function existUsers(EntityManager $entityManager): bool | 23 | static public function existUsers(EntityManager $entityManager): bool |
24 | { | 24 | { |
25 | // optimiser ça si possible, on veut juste savoir si la table est vide ou non | 25 | $nb_users = $entityManager |
26 | $users = $entityManager->getRepository(User::class)->findAll(); | 26 | ->createQuery('SELECT COUNT(u.id_user) FROM App\Entity\User u') |
27 | 27 | ->getSingleScalarResult(); | |
28 | if(count($users) === 0) // table vide | 28 | |
29 | if($nb_users === 0) // table vide | ||
29 | { | 30 | { |
30 | $_SESSION['user'] = ''; | 31 | $_SESSION['user'] = ''; |
31 | $_SESSION['admin'] = false; | 32 | $_SESSION['admin'] = false; |
32 | |||
33 | return false; | 33 | return false; |
34 | } | 34 | } |
35 | else{ | 35 | else{ |