diff options
Diffstat (limited to 'src/controller/PageManagementController.php')
| -rw-r--r-- | src/controller/PageManagementController.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php index f84c528..50ce193 100644 --- a/src/controller/PageManagementController.php +++ b/src/controller/PageManagementController.php | |||
| @@ -6,6 +6,7 @@ declare(strict_types=1); | |||
| 6 | use App\Entity\Page; | 6 | use App\Entity\Page; |
| 7 | use App\Entity\Node; | 7 | use App\Entity\Node; |
| 8 | use App\Entity\NodeData; | 8 | use App\Entity\NodeData; |
| 9 | use App\Entity\Presentation; | ||
| 9 | //use App\Entity\Image; | 10 | //use App\Entity\Image; |
| 10 | use Doctrine\Common\Collections\ArrayCollection; | 11 | use Doctrine\Common\Collections\ArrayCollection; |
| 11 | use Doctrine\ORM\EntityManager; | 12 | use Doctrine\ORM\EntityManager; |
| @@ -136,8 +137,7 @@ class PageManagementController | |||
| 136 | $main = $director->getNode(); | 137 | $main = $director->getNode(); |
| 137 | $position = count($main->getChildren()) + 1; // position dans la fraterie | 138 | $position = count($main->getChildren()) + 1; // position dans la fraterie |
| 138 | 139 | ||
| 139 | $blocks = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php | 140 | if(!in_array($_POST["bloc_select"], Blocks::getNameList(), true)) // 3è param: contrôle du type |
| 140 | if(!in_array($_POST["bloc_select"], $blocks, true)) // 3è param: contrôle du type | ||
| 141 | { | 141 | { |
| 142 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); | 142 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); |
| 143 | die; | 143 | die; |
| @@ -163,7 +163,7 @@ class PageManagementController | |||
| 163 | $entityManager->persist($bulk_data[0]); | 163 | $entityManager->persist($bulk_data[0]); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | $bloc = new Node( | 166 | $block = new Node( |
| 167 | $_POST["bloc_select"], | 167 | $_POST["bloc_select"], |
| 168 | null, [], | 168 | null, [], |
| 169 | $position, | 169 | $position, |
| @@ -171,9 +171,17 @@ class PageManagementController | |||
| 171 | $page); | 171 | $page); |
| 172 | $data = new NodeData( | 172 | $data = new NodeData( |
| 173 | ['title' => trim(htmlspecialchars($_POST["bloc_title"]))], | 173 | ['title' => trim(htmlspecialchars($_POST["bloc_title"]))], |
| 174 | $bloc); | 174 | $block); |
| 175 | 175 | ||
| 176 | $entityManager->persist($bloc); | 176 | // valeurs par défaut |
| 177 | if($_POST["bloc_select"] === 'post_block'){ | ||
| 178 | $data->setPresentation($entityManager->find('App\Entity\Presentation', 1)); // pas génial l'utilisation de l'index dans la table | ||
| 179 | } | ||
| 180 | elseif($_POST["bloc_select"] === 'news_block'){ | ||
| 181 | $data->setPresentation($entityManager->find('App\Entity\Presentation', 2)); | ||
| 182 | } | ||
| 183 | |||
| 184 | $entityManager->persist($block); | ||
| 177 | $entityManager->persist($data); | 185 | $entityManager->persist($data); |
| 178 | $entityManager->flush(); | 186 | $entityManager->flush(); |
| 179 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); | 187 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); |
