From df3612ed7e6691530503f79483d2fdbc032d01b8 Mon Sep 17 00:00:00 2001 From: polo-pc-greta Date: Thu, 27 Mar 2025 10:13:03 +0100 Subject: mise en ligne github --- src/model/Menu.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/model/Menu.php (limited to 'src/model/Menu.php') diff --git a/src/model/Menu.php b/src/model/Menu.php new file mode 100644 index 0000000..624a0fc --- /dev/null +++ b/src/model/Menu.php @@ -0,0 +1,53 @@ +children = new ArrayCollection(); + + $bulk_data = $entityManager + ->createQuery('SELECT n FROM App\Entity\Page n WHERE n.parent IS null') // :Doctrine\ORM\Query + ->getResult(); // :array de Page + + if(count($bulk_data) === 0){ + makeStartPage($entityManager); + } + + foreach($bulk_data as $first_level_entries){ + // génération du menu + if($first_level_entries->getInMenu()){ + $this->addChild($first_level_entries); + } + // autres pages + else{ + // attention, seul le premier élément du chemin est pris en compte + $this->other_pages[] = $first_level_entries; + } + } + + foreach($this->getChildren() as $page){ + $page->fillChildrenPagePath(); + } + + /*for($i = 0; $i < count($this->getChildren()[1]->getChildren()); $i++){ + echo $this->getChildren()[1]->getChildren()[$i]->getEndOfPath() . ' - '; + echo $this->getChildren()[1]->getChildren()[$i]->getPageName() . '
'; + }*/ + //die; + } + + public function getOtherPages(): array + { + return $this->other_pages; + } +} \ No newline at end of file -- cgit v1.2.3