Пример #1
0
 /**
  * Deletes a Layout entity.
  *
  * @Route("/{id}", name="layout_delete")
  * @Method("DELETE")
  */
 public function deleteAction(Request $request, Layout $entity)
 {
     $form = $this->createDeleteForm($entity->getId());
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $entity->getChildren()->clear();
         $em->remove($entity);
         $em->flush();
     }
     return $this->redirect($this->generateUrl('layout_edition'));
 }
Пример #2
0
 public function recursiveTransform($children, $root, $parent)
 {
     $em = $this->em;
     foreach ($children as $child) {
         $tag = $child['tag'];
         $classes = $child['cssClass'];
         $matches = $this->extractClasses($classes);
         $new = new Layout();
         $new->setCssClasses($matches);
         $new->setTag($tag);
         $new->setRoot($root);
         $new->setParent($parent);
         $em->persist($new);
         $root->addSub($new);
         $parent->addChild($new);
         $em->flush($new);
         if (isset($child['children'])) {
             $this->recursiveTransform($child['children'], $root, $new);
         }
     }
 }
Пример #3
0
 public function __toString()
 {
     $name = $this->root ? $this->root->getName() : $this->name;
     return $name . " - " . $this->position;
 }