public function __invoke($id, $type) { $seo = $this->seoService->getSeoByTypeId($id, $type); if ($seo) { $view = $this->getView(); $view->headTitle()->append(ucfirst($seo->getTitle())); $view->headMeta()->appendName('description', $this->cutText($seo->getDescription(), 155)); $view->headMeta()->setName('keywords', $seo->getKeywords()); return $view; } }
public function removeAction() { if (!($seo = $this->loadObject($this->seoService, "Seo doesn't exist."))) { return $this->redirect()->toRoute('seo', array('action' => 'list')); } if ($this->request->isPost()) { $del = $this->request->getPost('del', 'No'); if ($del == 'Yes') { $this->seoService->remove($seo); $this->flashMessenger()->addSuccessMessage('Seo record has been removed.'); } return $this->redirect()->toRoute('seo', array('action' => 'list')); } $view = new ViewModel(array('seo' => $seo)); $view->setTerminal(true); return $view; }
public function renderSeo(EventInterface $e) { $sm = $e->getApplication()->getServiceManager(); $config = $sm->get('config'); $routes = $config['seo']['seo_routes']; $seoRoute = $e->getRouteMatch()->getMatchedRouteName(); $params = $e->getRouteMatch()->getParams(); $id = $params['id']; $type = $routes[$seoRoute]; $seo = $this->seoService->getSeoByTypeId($id, $type); if ($seo) { // get view Model $renderer = $sm->get('Zend\\View\\Renderer\\PhpRenderer'); $renderer->headTitle()->append(ucfirst($seo->getTitle())); $renderer->headMeta()->appendName('description', $seo->getDescription()); $renderer->headMeta()->setName('keywords', $seo->getKeywords()); } // return response return $e->getResponse(); }