summaryrefslogtreecommitdiff
path: root/src/controller/Director.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller/Director.php')
-rw-r--r--src/controller/Director.php26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/controller/Director.php b/src/controller/Director.php
index 56a90cb..b154432 100644
--- a/src/controller/Director.php
+++ b/src/controller/Director.php
@@ -36,6 +36,7 @@ class Director
36 return $this->article; 36 return $this->article;
37 } 37 }
38 38
39 // affichage d'une page ordinaire
39 public function makeRootNode(string $id = ''): void 40 public function makeRootNode(string $id = ''): void
40 { 41 {
41 // on récupère toutes les entrées 42 // on récupère toutes les entrées
@@ -91,6 +92,12 @@ class Director
91 } 92 }
92 } 93 }
93 94
95 // le basique
96 public function findNodeById(int $id): void
97 {
98 $this->node = $this->entityManager->find('App\Entity\Node', $id);
99 }
100
94 // récupération d'un article pour modification 101 // récupération d'un article pour modification
95 public function makeArticleNode(string $id = '', bool $get_section = false): bool 102 public function makeArticleNode(string $id = '', bool $get_section = false): bool
96 { 103 {
@@ -112,7 +119,8 @@ class Director
112 119
113 if($get_section){ 120 if($get_section){
114 $this->article = $bulk_data[0]; 121 $this->article = $bulk_data[0];
115 $this->makeSectionNode($bulk_data[0]->getParent()->getId()); 122 $this->findNodeById($bulk_data[0]->getParent()->getId());
123 $this->makeSectionNode();
116 } 124 }
117 else{ 125 else{
118 $this->article = $bulk_data[0]; 126 $this->article = $bulk_data[0];
@@ -122,31 +130,30 @@ class Director
122 } 130 }
123 131
124 // récupération des articles d'un bloc <section> à la création d'un article 132 // récupération des articles d'un bloc <section> à la création d'un article
125 public function makeSectionNode(int $section_id): bool 133 public function makeSectionNode(): bool
126 { 134 {
127 $section = $this->entityManager->find('App\Entity\Node', (string)$section_id);
128
129 $bulk_data = $this->entityManager 135 $bulk_data = $this->entityManager
130 ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent') 136 ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent')
131 ->setParameter('parent', $section) 137 ->setParameter('parent', $this->node)
132 ->getResult(); 138 ->getResult();
133 139
134 foreach($bulk_data as $article){ 140 foreach($bulk_data as $article){
135 $section->addChild($article); // pas de flush, on ne va pas écrire dans la BDD à chaque nouvelle page 141 $this->node->addChild($article); // pas de flush, on ne va pas écrire dans la BDD à chaque nouvelle page
136 } 142 }
137 $this->node = $section;
138 return true; 143 return true;
139 } 144 }
140 145
141 public function findNodeByName(string $name): void 146 public function findUniqueNodeByName(string $name): void // = unique en BDD, donc sans "page" associée
142 { 147 {
143 $bulk_data = $this->entityManager 148 $bulk_data = $this->entityManager
144 ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.name_node = :name') 149 ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.name_node = :name')
145 ->setParameter('name', $name) 150 ->setParameter('name', $name)
146 ->getResult(); 151 ->getResult();
147 $this->node = $bulk_data[0]; 152 $this->node = $bulk_data[0];
148 echo $this->page->getPageName() . ' '; 153 }
149 154
155 public function findItsChildren(): void
156 {
150 $bulk_data = $this->entityManager 157 $bulk_data = $this->entityManager
151 ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent AND n.page = :page') 158 ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent AND n.page = :page')
152 ->setParameter('parent', $this->node) 159 ->setParameter('parent', $this->node)
@@ -154,7 +161,6 @@ class Director
154 ->getResult(); 161 ->getResult();
155 foreach($bulk_data as $child){ 162 foreach($bulk_data as $child){
156 $this->node->addChild($child); 163 $this->node->addChild($child);
157 echo $child->getName() . ' ';
158 } 164 }
159 } 165 }
160} 166}