From 3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 1 Nov 2025 23:35:25 +0100 Subject: renommage pour mes yeux --- src/controller/MenuAndPathsController.php | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/controller/MenuAndPathsController.php') diff --git a/src/controller/MenuAndPathsController.php b/src/controller/MenuAndPathsController.php index 6bb098f..4d37f3d 100644 --- a/src/controller/MenuAndPathsController.php +++ b/src/controller/MenuAndPathsController.php @@ -10,8 +10,8 @@ class MenuAndPathsController { static public function newUrlMenuEntry(EntityManager $entityManager): void { - Model::$menu_data = new Menu($entityManager); - $previous_page = Model::$menu_data->findPageById((int)$_POST["location"]); // (int) à cause de declare(strict_types=1); + Model::$menu = new Menu($entityManager); + $previous_page = Model::$menu->findPageById((int)$_POST["location"]); // (int) à cause de declare(strict_types=1); $parent = $previous_page->getParent(); $url_input = trim($_POST["url_input"]); // faire htmlspecialchars à l'affichage @@ -31,7 +31,7 @@ class MenuAndPathsController // addChild l'ajoute à la fin du tableau "children" puis on trie // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position if(!$parent){ - $parent = Model::$menu_data; + $parent = Model::$menu; } $parent->addChild($page); // true pour réindexer les positions en BDD $parent->reindexPositions(); @@ -72,11 +72,11 @@ class MenuAndPathsController static public function deleteUrlMenuEntry(EntityManager $entityManager): void { - Model::$menu_data = new Menu($entityManager); - $page = Model::$menu_data->findPageById((int)$_POST["delete"]); + Model::$menu = new Menu($entityManager); + $page = Model::$menu->findPageById((int)$_POST["delete"]); $parent = $page->getParent(); if($parent == null){ - $parent = Model::$menu_data; + $parent = Model::$menu; } $parent->removeChild($page); // suppression de $children avant de trier @@ -91,7 +91,7 @@ class MenuAndPathsController static public function MoveOneLevelUp(EntityManager $entityManager, array $json): void { $id = $json['id']; - $page = Model::$menu_data->findPageById((int)$id); + $page = Model::$menu->findPageById((int)$id); $parent = $page->getParent(); // peut être null if($parent === null){ @@ -103,12 +103,12 @@ class MenuAndPathsController else{ $page->setPosition($parent->getPosition() + 1); // nouvelle position - // 2ème niveau: le parent devient $menu_data, puis null après tri + // 2ème niveau: le parent devient $menu, puis null après tri if($parent->getParent() === null){ // connexion dans les deux sens - $page->setParent(Model::$menu_data); // => pour la persistance + $page->setParent(Model::$menu); // => pour la persistance - //Model::$menu_data->addChild($page); // => pour sortChildren + //Model::$menu->addChild($page); // => pour sortChildren $page->getParent()->addChild($page); // => pour sortChildren $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères $page->setParent(null); @@ -138,11 +138,11 @@ class MenuAndPathsController static public function MoveOneLevelDown(EntityManager $entityManager, array $json): void { $id = $json['id']; - $page = Model::$menu_data->findPageById((int)$id); + $page = Model::$menu->findPageById((int)$id); $parent = $page->getParent(); // peut être null if($parent == null){ - $parent = Model::$menu_data; + $parent = Model::$menu; } // BDD @@ -175,8 +175,8 @@ class MenuAndPathsController $id2 = $json['id2']; // vérifier qu'ils ont le même parent - $page1 = Model::$menu_data->findPageById((int)$id1); - $page2 = Model::$menu_data->findPageById((int)$id2); + $page1 = Model::$menu->findPageById((int)$id1); + $page2 = Model::$menu->findPageById((int)$id2); // double le contrôle fait en JS if($page1->getParent() === $page2->getParent()) // comparaison stricte d'objet (même instance du parent?) @@ -185,7 +185,7 @@ class MenuAndPathsController $tmp = $page1->getPosition(); $page1->setPosition($page2->getPosition()); $page2->setPosition($tmp); - Model::$menu_data->sortChildren(true); // modifie tableau children + Model::$menu->sortChildren(true); // modifie tableau children $entityManager->flush(); // nouveau menu @@ -203,7 +203,7 @@ class MenuAndPathsController $id = $json['id']; $checked = $json['checked']; - $page = Model::$menu_data->findPageById((int)$id); + $page = Model::$menu->findPageById((int)$id); if($page->isHidden() === $checked){ $page->setHidden(!$checked); $entityManager->flush(); -- cgit v1.2.3