@@ 166-185 (lines=20) @@ | ||
163 | $em = $eventArgs->getEntityManager(); |
|
164 | //find all BT that can represent the businessEntity |
|
165 | $businessTemplates = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->findPagePatternByBusinessEntity($businessEntity); |
|
166 | foreach ($businessTemplates as $businessTemplate) { |
|
167 | if ($page = $em->getRepository( |
|
168 | 'Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage' |
|
169 | )->findPageByBusinessEntityAndPattern($businessTemplate, $entity, $businessEntity) |
|
170 | ) { |
|
171 | //if it's a BP we update the BP |
|
172 | $this->businessPageBuilder->updatePageParametersByEntity($page, $entity); |
|
173 | } else { |
|
174 | $page = $this->businessPageBuilder->generateEntityPageFromTemplate( |
|
175 | $businessTemplate, |
|
176 | $entity, |
|
177 | $em |
|
178 | ); |
|
179 | } |
|
180 | if ($this->businessPageHelper->isEntityAllowed($businessTemplate, $entity, $em)) { |
|
181 | //update the reference |
|
182 | $event = new ViewReferenceEvent($page); |
|
183 | $this->dispatcher->dispatch(ViewReferenceEvents::UPDATE_VIEW_REFERENCE, $event); |
|
184 | } |
|
185 | } |
|
186 | } |
|
187 | //if it a businessTemplate we have to rebuild virtuals or update BP |
|
188 | if ($entity instanceof BusinessTemplate) { |
|
@@ 194-213 (lines=20) @@ | ||
191 | $businessEntity = $this->businessEntityHelper->findById($businessEntityId); |
|
192 | //find all entities |
|
193 | $entities = $this->businessPageHelper->getEntitiesAllowed($entity, $em); |
|
194 | foreach ($entities as $be) { |
|
195 | if ($this->businessPageHelper->isEntityAllowed($entity, $be, $em)) { |
|
196 | if ($page = $em->getRepository( |
|
197 | 'Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage' |
|
198 | )->findPageByBusinessEntityAndPattern($entity, $be, $businessEntity) |
|
199 | ) { |
|
200 | //rebuild page if its a BP |
|
201 | $this->businessPageBuilder->updatePageParametersByEntity($page, $be); |
|
202 | } else { |
|
203 | $page = $this->businessPageBuilder->generateEntityPageFromTemplate( |
|
204 | $entity, |
|
205 | $be, |
|
206 | $em |
|
207 | ); |
|
208 | } |
|
209 | // update reference |
|
210 | $event = new ViewReferenceEvent($page); |
|
211 | $this->dispatcher->dispatch(ViewReferenceEvents::UPDATE_VIEW_REFERENCE, $event); |
|
212 | } |
|
213 | } |
|
214 | } |
|
215 | } |
|
216 |