Пример #1
0
 /**
  * Creates a form to edit a Page entity.
  *
  * @param Page $entity The entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createEditForm(Page $entity)
 {
     $showParent = false;
     $showURL = true;
     if ($entity->getLvl() > 0) {
         $showParent = true;
     } else {
         $showURL = false;
     }
     $siteId = $this->getRequest()->get('site_id');
     $form = $this->createForm(new PageType(), $entity, array('action' => $this->generateUrl('cmf_admin_page_update', array('id' => $entity->getId(), 'site_id' => $siteId)), 'method' => 'PUT', 'SHOW_PARENT' => $showParent, 'SHOW_URL' => $showURL, 'SITE_ID' => $siteId));
     $form->add('submit', 'submit', array('label' => 'Сохранить', 'attr' => array('class' => 'btn btn-success')));
     return $form;
 }
Пример #2
0
 private function getPageArray($page)
 {
     $site = $this->getSite();
     $twig = new \Twig_Environment(new \Twig_Loader_String());
     $twig->addExtension(new \Symfony\Bridge\Twig\Extension\HttpKernelExtension($this->get('fragment.handler')));
     $rendered = '';
     $rendered = $twig->render($page->getContent(), array());
     $page->setContent($rendered);
     $template = $this->getTemplate($site['code'], 'default');
     if (!($templateName = $page->getTemplate())) {
         //echo '<pre>' . print_r('не было шаблона', true) . '</pre>';
         $page->setTemplate($template);
     } else {
         $page->setTemplate($this->getTemplate($site['code'], $templateName));
     }
     /**
      * Рендерим контент страницы
      */
     $twig = new \Twig_Environment(new \Twig_Loader_String());
     $twig->addExtension(new \Symfony\Bridge\Twig\Extension\HttpKernelExtension($this->get('fragment.handler')));
     $rendered = $twig->render($page->getContent(), array());
     //echo '<pre>' . print_r($page->getTitle(), true) . '</pre>'; exit;
     $new_page = new Page();
     $new_page->setContent($rendered);
     $new_page->setController($page->getController());
     $new_page->setDescription($page->getDescription());
     $new_page->setHeader($page->getHeader());
     $new_page->setName($page->getName());
     $new_page->setUrl($page->getUrl());
     $new_page->setTitle($page->getTitle());
     $new_page->setTemplate($page->getTemplate());
     $new_page->setRoot($page->getRoot());
     return $new_page;
 }
Пример #3
0
 private function deletePreviewPicture(\Novuscom\CMFBundle\Entity\Page $element)
 {
     $em = $this->getDoctrine()->getManager();
     $previewPicture = $element->getPreviewPicture();
     if ($previewPicture) {
         $element->setPreviewPicture(null);
         $em->persist($element);
         $em->remove($previewPicture);
         $fileName = $_SERVER['DOCUMENT_ROOT'] . '/upload/images/' . $previewPicture->getName();
         $em->flush();
         unlink($fileName);
     }
 }