Beispiel #1
0
 /**
  * Create Layout
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function createAction()
 {
     $layoutForm = new LayoutForm();
     $layoutForm->setAttribute('action', $this->url()->fromRoute('development/layout/create'));
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost()->toArray();
         $layoutForm->setData($data);
         if (!$layoutForm->isValid()) {
             $this->flashMessenger()->addErrorMessage('Can not save layout');
             $this->useFlashMessenger();
         } else {
             $layoutModel = new Layout\Model();
             $layoutModel->setName($layoutForm->getValue('name'));
             $layoutModel->setIdentifier($layoutForm->getValue('identifier'));
             $layoutModel->setDescription($layoutForm->getValue('description'));
             $layoutModel->setContent($layoutForm->getValue('content'));
             $layoutModel->save();
             $this->flashMessenger()->addSuccessMessage('This layout has been created');
             return $this->redirect()->toRoute('development/layout/edit', array('id' => $layoutModel->getId()));
         }
     }
     return array('form' => $layoutForm);
 }