Exemple #1
0
 public function editAction()
 {
     $this->view->changeRender('admin/block/create');
     $block = Block::findFirst($this->dispatcher->getParam('id'));
     if (!$block) {
         throw new Exception\ResourceNotFoundException('ERR_BLOCK_NOT_FOUND');
     }
     $form = new BlockForm();
     $form->setModel($block);
     $this->view->setVar('item', $block);
     $this->view->setVar('form', $form);
     if (!$this->request->isPost()) {
         return false;
     }
     $data = $this->request->getPost();
     if (!$form->isFullValid($data)) {
         return $this->showInvalidMessages($form);
     }
     try {
         $form->save();
     } catch (\Exception $e) {
         return $this->showException($e, $form->getModel()->getMessages());
     }
     $this->flashSession->success('SUCCESS_BLOCK_UPDATED');
     return $this->redirectHandler('/admin/block/edit/' . $block->id);
 }
Exemple #2
0
 public function __invoke($name)
 {
     $block = Block::findFirst("name='{$name}'");
     $content = '';
     if ($block && $block->visibility == 'visible') {
         $content = $block->content;
     }
     return $content;
 }