From 027af942de75f7c5bc519fabfa5fa11de9bc89ea Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 17 Sep 2025 16:52:43 +0200 Subject: =?UTF-8?q?optimisation=20r=C3=A9cursivit=C3=A9=20dans=20sortChild?= =?UTF-8?q?ren=20uniquement=20avec=20les=20pages,=20regression=20construct?= =?UTF-8?q?eur=20MenuBuilder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Config.php | 2 +- src/controller/MenuAndPathsController.php | 2 -- src/model/Position.php | 10 +++++++--- src/view/MenuBuilder.php | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Config.php b/src/Config.php index baf4d6d..662344b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -25,7 +25,7 @@ class Config static public string $smtp_secure = ''; // tls (smarttls) ou ssl (smtps) ou plain_text/chaine vide static public string $email_from = 'mon_adresse@email.fr'; static public string $email_from_name = 'site web'; - static public string $email_dest = 'mon_adresse@email.fr'; + static public string $email_dest = ''; static public string $email_dest_name = 'destinataire formulaire'; // copier dans ce tableau les variables contenant des chemins diff --git a/src/controller/MenuAndPathsController.php b/src/controller/MenuAndPathsController.php index 5779b39..3ff7d54 100644 --- a/src/controller/MenuAndPathsController.php +++ b/src/controller/MenuAndPathsController.php @@ -101,7 +101,6 @@ class MenuAndPathsController //Director::$menu_data->addChild($page); // => pour sortChildren $page->getParent()->addChild($page); // => pour sortChildren - //Director::$menu_data->sortChildren(true); // positions décaléees des nouveaux petits frères $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères $page->setParent(null); @@ -116,7 +115,6 @@ class MenuAndPathsController $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères $page->fillChildrenPagePath($page->getParent()->getPagePath()); } - //$parent->sortChildren(true); // positions des enfants restants, inutile si la fonction est récursive? $entityManager->flush(); // affichage diff --git a/src/model/Position.php b/src/model/Position.php index 8035481..fdba271 100644 --- a/src/model/Position.php +++ b/src/model/Position.php @@ -23,9 +23,13 @@ trait Position $this->children[$j + 1] = $tmp; } - foreach($this->children as $child) { - if(count($child->children) > 0) { - $child->sortChildren($reindexation); + // récursivité (utile dans Menu et chemin) + // appel dans Page et dans MenuAndPathController (un tri supplémentaire à faire?) + if(self::class === 'App\Entity\Page'){ + foreach($this->children as $child) { + if(count($child->children) > 0) { + $child->sortChildren($reindexation); + } } } diff --git a/src/view/MenuBuilder.php b/src/view/MenuBuilder.php index bc64e30..8ea4b8e 100644 --- a/src/view/MenuBuilder.php +++ b/src/view/MenuBuilder.php @@ -13,7 +13,7 @@ class MenuBuilder extends AbstractBuilder //private int $margin_left_multiplier = 29; private string $options = ''; - public function __construct(Node $node, bool $template = true) + public function __construct(?Node $node, bool $template = true) { // impossible de me rappeler pourquoi j'ai écrit ce test sur $node, pourquoi $node serait null? $viewFile = $node === null ? self::VIEWS_PATH . 'menu.php' : self::VIEWS_PATH . $node->getName() . '.php'; -- cgit v1.2.3