Beispiel #1
0
 public function showAction($anchor = "home", $site = "main", Request $request)
 {
     $from = $this->container->getParameter('mailer_from');
     $to = $this->container->getParameter('mailer_to');
     $conf = $this->get('cms_conf');
     $menu = $this->getRepository()->findBy(array('isMenu' => true), array('itemorder' => 'ASC'));
     $sitee = $this->getSiteRepository()->findOneByName($site);
     $page = $this->getRepository()->findSitePage($site, $anchor);
     if (!$page) {
         throw $this->createNotFoundException('Unable to find Section entity.');
     }
     $view = $conf->getPageView($page->getType());
     //$view=$conf->getPageView('home');
     if ($this->get('templating')->exists("SoftlogoCMSBundle:Page:{$view}")) {
         $viewpath = "SoftlogoCMSBundle:Page:{$view}";
     } else {
         $viewpath = "SoftlogoCMSBundle:Page:page.html.twig";
     }
     $contact = new Contact();
     $contact->setNazwisko('Borys Jankiewicz');
     $contact->setTitle('Formularz kontaktowy');
     $form = $this->createFormBuilder($contact)->add('message', null, array('label' => 'Wiadomość'))->add('email')->add('save', 'submit', array('label' => 'Wyślij'))->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $mailHelper = $this->container->get('mail_helper');
         $mailHelper->sendEmailWithView($from, $to, $contact->getTitle(), "SoftlogoCMSBundle:Contact:contact.html.twig", array("message" => $contact->getMessage(), "email" => $contact->getEmail()));
         $flash = $this->get('braincrafted_bootstrap.flash');
         $flash->success('Formularz został wysłany.');
         //return $this->redirect($this->generateUrl('form-informacja'));
     }
     return $this->render($viewpath, array('site' => $sitee, 'page' => $page, 'title' => $page->getTitle(), 'menu' => $menu, 'form' => $form->createView()));
 }
 public function formAction(Request $request)
 {
     $contact = new Contact();
     $contact->setNazwisko('Borys Jankiewicz');
     $form = $this->createFormBuilder($contact)->add('title')->add('message')->add('email')->add('save', 'submit')->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         // perform some action, such as saving the task to the database
         //$this->get('session')->getFlashBag()->add('notice', 'Your changes were saved!');
         $flash = $this->get('braincrafted_bootstrap.flash');
         $flash->success('Formularz został wysłany.');
         return $this->redirect($this->generateUrl('form-informacja'));
     }
     return $this->render("SoftlogoCMSBundle:Contact:form.html.twig", array('form' => $form->createView(), 'title' => "Formularz"));
 }