public function saveHeadmetaAction()
 {
     $request = $this->getRequest();
     $headmetaTable = new HeadmetaTable($this->getServiceLocator()->get('dbAdapter'));
     if ($request->isPost()) {
         $postData = $request->getPost();
         $headmeta = new Headmeta();
         $form = new HeadmetaForm();
         $form->setData($postData);
         if ($form->isValid()) {
             $data = $form->getData();
             $headmeta->exchangeArray($data);
             $headmetaTable->saveHeadMeta($headmeta);
         }
     }
     return $this->redirect()->toUrl($_SERVER['HTTP_REFERER']);
 }
Example #2
0
 public function __invoke()
 {
     if ($this->routeMatch) {
         $controller = $this->routeMatch->getParam('controller');
         $action = $this->routeMatch->getParam('action');
         $controllerName = explode('\\', $controller);
         $dbAdapter = $this->serviceLocator->get('DbAdapter');
         $headmetaTable = new HeadmetaTable($dbAdapter);
         $headmeta = $headmetaTable->getMetaByControllerAndAction(strtolower($controllerName[2]), $action);
         $this->authService = $this->serviceLocator->get('AuthService');
         if ($this->authService->hasIdentity()) {
             $form = new HeadmetaForm();
             $form->bind($headmeta);
             return array('title' => $headmeta->title, 'description' => $headmeta->description, 'keywords' => $headmeta->keywords, 'form' => $form);
         }
         return array('title' => $headmeta->title, 'description' => $headmeta->description, 'keywords' => $headmeta->keywords, 'form' => null);
     }
 }