public function jsonAction() { $this->initializeFrontendWebsite(); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $id = $this->params()->fromRoute('id'); $helper = new PostsControllerHelper(); $wrapper = $helper->recoverWrapperById(new PostsGetterWrapper(new PostsGetter($em)), array('id' => $id, 'limit' => 1), $id); $wrapper->setEntityManager($em); $records = $wrapper->addAttachmentsFromRecords($wrapper->getRecords(), array()); if (empty($records)) { return $this->redirectForUnvalidAccess(); } $record = $records[0]; return new JsonModel(array('Titolo' => $record['title'], 'Sottotitolo' => $record['subtitle'], 'Descrizione' => $record['description'])); }