/**
  * Albo atto details page
  */
 public function detailsAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $id = $this->params()->fromRoute('id');
     try {
         $helper = new AlboPretorioControllerHelper();
         $wrapper = $helper->recoverWrapperById(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), array('id' => $id, 'limit' => 1), $id);
         $attoRecord = $wrapper->getRecords();
         $helper->checkRecords($attoRecord, 'Nessun atto albo pretorio trovato');
         $wrapper->setEntityManager($em);
         $records = $wrapper->addAttachmentsFromRecords($attoRecord, array('moduleId' => ModulesContainer::albo_pretorio_id, 'noScaduti' => 1, 'orderBy' => 'a.position'));
         $this->layout()->setVariables(array('records' => $records, 'templatePartial' => 'albo-pretorio/albo-pretorio-details.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageType' => 'secondary', 'moduleLabel' => "Albo pretorio", 'messageTitle' => "Nessun albo pretorio trovato", 'messageText' => "Impossibile visualizzare i dati richiesti sul sito pubblico", 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
 /**
  * @return \Zend\Http\Response|JsonModel
  */
 public function jsonAction()
 {
     $this->initializeFrontendWebsite();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $id = $this->params()->fromRoute('id');
     $helper = new AlboPretorioControllerHelper();
     $wrapper = $helper->recoverWrapperById(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($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['titolo'], 'Numero' => $record['numeroAtto'], 'Anno' => $record['anno'], 'Scadenza' => $record['dataScadenza']->format("d-m-Y"), 'Sezione' => $record['nomeSezione']));
 }