public function indexAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $subsectionid = $this->params()->fromRoute('subsectionid');
     $lang = $this->params()->fromRoute('lang');
     /**
      * @var \Doctrine\ORM\EntityManager $em
      */
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $ammTraspSezioneId = $this->layout()->getVariable('amministrazione_trasparente_sezione_id');
     $helper = new ContenutiControllerHelper();
     $wrapper = $helper->recoverWrapper(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('noscaduti' => 1, 'attivo' => 1, 'modulo' => ModulesContainer::contenuti_id, 'sottosezione' => $subsectionid, 'languageAbbreviation' => $lang));
     $wrapper->setEntityManager($em);
     $records = $wrapper->addAttachmentsFromRecords($wrapper->getRecords(), array('moduleId' => ModulesContainer::contenuti_id, 'noscaduti' => 1, 'languageAbbreviation' => $lang, 'orderBy' => 'a.position'));
     if (!empty($records)) {
         foreach ($records as &$record) {
             $wrapper = new SottoSezioniGetterWrapper(new SottoSezioniGetter($em));
             $wrapper->setInput(array('profonditaDa' => isset($record['sottosezione']) ? $record['sottosezione'] : null, 'excludeSezioneId' => isset($ammTraspSezioneId) ? $ammTraspSezioneId : null));
             $wrapper->setupQueryBuilder();
             $subSections = $wrapper->getRecords();
             if (!empty($subSections)) {
                 foreach ($subSections as $subSection) {
                     $record['sotto_sezioni'][] = $subSection;
                 }
             }
         }
     }
     $this->layout()->setVariables(array('records' => isset($records) ? $records : null, 'recordsCount' => count($records), 'templatePartial' => 'contenuti/contenuti-list.phtml'));
     $this->layout()->setTemplate($mainLayout);
 }
 /**
  * @param array $input
  * @return \ModelModule\Model\QueryBuilderHelperAbstract
  */
 private function getSottoSezioniRecords($input = array())
 {
     $wrapper = new SottoSezioniGetterWrapper(new SottoSezioniGetter($this->getServiceLocator()->get('doctrine.entitymanager.orm_default')));
     $wrapper->setInput($input);
     $wrapper->setupQueryBuilder();
     return $wrapper->getRecords();
 }
 /**
  * @param array $records
  * @param array $inputToMerge
  * @return array
  */
 public function addSottoSezioni($records, $inputToMerge = array())
 {
     if (!empty($records)) {
         foreach ($records as &$record) {
             $wrapper = new SottoSezioniGetterWrapper(new SottoSezioniGetter($this->objectGetter->getEntityManager()));
             $wrapper->setInput(array_merge(array('sezioneId' => isset($record['id']) ? $record['id'] : null, 'orderBy' => 'sottosezioni.posizione', 'isSs' => 0), $inputToMerge));
             $wrapper->setupQueryBuilder();
             $record['sottosezioni'] = is_array($wrapper->getRecords()) ? $wrapper->getRecords() : null;
         }
         return $records;
     }
 }