diff options
author | polo <ordipolo@gmx.fr> | 2025-09-17 16:52:43 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-09-17 16:52:43 +0200 |
commit | 027af942de75f7c5bc519fabfa5fa11de9bc89ea (patch) | |
tree | f8074c57d59e99e036152369f2808046aa0004ec | |
parent | 07819d9f9e151e9fed6a6490dcad53ba2d57a550 (diff) | |
download | cms-027af942de75f7c5bc519fabfa5fa11de9bc89ea.zip |
optimisation récursivité dans sortChildren uniquement avec les pages, regression constructeur MenuBuilder
-rw-r--r-- | src/Config.php | 2 | ||||
-rw-r--r-- | src/controller/MenuAndPathsController.php | 2 | ||||
-rw-r--r-- | src/model/Position.php | 10 | ||||
-rw-r--r-- | 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 | |||
25 | static public string $smtp_secure = ''; // tls (smarttls) ou ssl (smtps) ou plain_text/chaine vide | 25 | static public string $smtp_secure = ''; // tls (smarttls) ou ssl (smtps) ou plain_text/chaine vide |
26 | static public string $email_from = 'mon_adresse@email.fr'; | 26 | static public string $email_from = 'mon_adresse@email.fr'; |
27 | static public string $email_from_name = 'site web'; | 27 | static public string $email_from_name = 'site web'; |
28 | static public string $email_dest = 'mon_adresse@email.fr'; | 28 | static public string $email_dest = ''; |
29 | static public string $email_dest_name = 'destinataire formulaire'; | 29 | static public string $email_dest_name = 'destinataire formulaire'; |
30 | 30 | ||
31 | // copier dans ce tableau les variables contenant des chemins | 31 | // 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 | |||
101 | 101 | ||
102 | //Director::$menu_data->addChild($page); // => pour sortChildren | 102 | //Director::$menu_data->addChild($page); // => pour sortChildren |
103 | $page->getParent()->addChild($page); // => pour sortChildren | 103 | $page->getParent()->addChild($page); // => pour sortChildren |
104 | //Director::$menu_data->sortChildren(true); // positions décaléees des nouveaux petits frères | ||
105 | $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères | 104 | $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères |
106 | $page->setParent(null); | 105 | $page->setParent(null); |
107 | 106 | ||
@@ -116,7 +115,6 @@ class MenuAndPathsController | |||
116 | $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères | 115 | $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères |
117 | $page->fillChildrenPagePath($page->getParent()->getPagePath()); | 116 | $page->fillChildrenPagePath($page->getParent()->getPagePath()); |
118 | } | 117 | } |
119 | //$parent->sortChildren(true); // positions des enfants restants, inutile si la fonction est récursive? | ||
120 | $entityManager->flush(); | 118 | $entityManager->flush(); |
121 | 119 | ||
122 | // affichage | 120 | // 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 | |||
23 | $this->children[$j + 1] = $tmp; | 23 | $this->children[$j + 1] = $tmp; |
24 | } | 24 | } |
25 | 25 | ||
26 | foreach($this->children as $child) { | 26 | // récursivité (utile dans Menu et chemin) |
27 | if(count($child->children) > 0) { | 27 | // appel dans Page et dans MenuAndPathController (un tri supplémentaire à faire?) |
28 | $child->sortChildren($reindexation); | 28 | if(self::class === 'App\Entity\Page'){ |
29 | foreach($this->children as $child) { | ||
30 | if(count($child->children) > 0) { | ||
31 | $child->sortChildren($reindexation); | ||
32 | } | ||
29 | } | 33 | } |
30 | } | 34 | } |
31 | 35 | ||
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 | |||
13 | //private int $margin_left_multiplier = 29; | 13 | //private int $margin_left_multiplier = 29; |
14 | private string $options = ''; | 14 | private string $options = ''; |
15 | 15 | ||
16 | public function __construct(Node $node, bool $template = true) | 16 | public function __construct(?Node $node, bool $template = true) |
17 | { | 17 | { |
18 | // impossible de me rappeler pourquoi j'ai écrit ce test sur $node, pourquoi $node serait null? | 18 | // impossible de me rappeler pourquoi j'ai écrit ce test sur $node, pourquoi $node serait null? |
19 | $viewFile = $node === null ? self::VIEWS_PATH . 'menu.php' : self::VIEWS_PATH . $node->getName() . '.php'; | 19 | $viewFile = $node === null ? self::VIEWS_PATH . 'menu.php' : self::VIEWS_PATH . $node->getName() . '.php'; |