示例#1
0
 /**
  * List of all Ort entities
  */
 public function listAction()
 {
     if ($this->request->getFormat() === 'json') {
         $this->view->setVariablesToRender(['ort']);
     }
     $searchArr = [];
     if ($this->request->hasArgument('columns')) {
         $columns = $this->request->getArgument('columns');
         foreach ($columns as $column) {
             if (!empty($column['data']) && !empty($column['search']['value'])) {
                 $searchArr[$column['data']] = $column['search']['value'];
             }
         }
     }
     if ($this->request->hasArgument('order')) {
         $order = $this->request->getArgument('order');
         if (!empty($order)) {
             $orderDir = $order[0]['dir'];
             $orderById = $order[0]['column'];
             if (!empty($orderById)) {
                 $columns = $this->request->getArgument('columns');
                 $orderBy = $columns[$orderById]['data'];
             }
         }
     }
     if ($this->request->hasArgument('draw')) {
         $draw = $this->request->getArgument('draw');
     } else {
         $draw = 0;
     }
     $start = $this->request->hasArgument('start') ? $this->request->getArgument('start') : self::start;
     $length = $this->request->hasArgument('length') ? $this->request->getArgument('length') : self::length;
     if (empty($searchArr)) {
         if (isset($orderBy) && !empty($orderBy) && (isset($orderDir) && !empty($orderDir))) {
             if ($orderDir === 'asc') {
                 $orderArr = [$orderBy => \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING];
             } elseif ($orderDir === 'desc') {
                 $orderArr = [$orderBy => \TYPO3\Flow\Persistence\QueryInterface::ORDER_DESCENDING];
             }
         }
         if (isset($orderArr) && !empty($orderArr)) {
             $orderings = $orderArr;
         } else {
             $orderings = ['ort' => \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING];
         }
         $orts = $this->ortRepository->getCertainNumberOfOrt($start, $length, $orderings);
         $recordsTotal = $this->ortRepository->getNumberOfEntries();
     } else {
         if (isset($orderBy) && !empty($orderBy) && (isset($orderDir) && !empty($orderDir))) {
             if ($orderDir === 'asc') {
                 $orderArr = [$orderBy, 'ASC'];
             } elseif ($orderDir === 'desc') {
                 $orderArr = [$orderBy, 'DESC'];
             }
         }
         if (isset($orderArr) && !empty($orderArr)) {
             $orderings = $orderArr;
         } else {
             $orderings = ['ort', 'ASC'];
         }
         $orts = $this->ortRepository->searchCertainNumberOfOrt($start, $length, $orderings, $searchArr, 1);
         $recordsFiltered = $this->ortRepository->searchCertainNumberOfOrt($start, $length, $orderings, $searchArr, 2);
         $recordsTotal = $this->ortRepository->getNumberOfEntries();
     }
     if (!isset($recordsFiltered)) {
         $recordsFiltered = $recordsTotal;
     }
     $ortArr = [];
     foreach ($orts as $k => $ort) {
         if (is_object($ort)) {
             $uUID = $ort->getUUID();
             if (!empty($uUID)) {
                 $ortArr[$k]['uUID'] = $uUID;
             } else {
                 $ortArr[$k]['uUID'] = '';
             }
             $ortName = $ort->getOrt();
             if (!empty($ortName)) {
                 $ortArr[$k]['ort'] = $ortName;
             } else {
                 $ortArr[$k]['ort'] = '';
             }
             $gemeinde = $ort->getGemeinde();
             if (!empty($gemeinde)) {
                 $ortArr[$k]['gemeinde'] = $gemeinde;
             } else {
                 $ortArr[$k]['gemeinde'] = '';
             }
             $kreis = $ort->getKreis();
             if (!empty($kreis)) {
                 $ortArr[$k]['kreis'] = $kreis;
             } else {
                 $ortArr[$k]['kreis'] = '';
             }
             $wuestung = $ort->getWuestung();
             if (!empty($wuestung)) {
                 $ortArr[$k]['wuestung'] = $wuestung;
             } else {
                 $ortArr[$k]['wuestung'] = '';
             }
             $breite = $ort->getBreite();
             if (!empty($breite)) {
                 $ortArr[$k]['breite'] = $breite;
             } else {
                 $ortArr[$k]['breite'] = '';
             }
             $laenge = $ort->getLaenge();
             if (!empty($laenge)) {
                 $ortArr[$k]['laenge'] = $laenge;
             } else {
                 $ortArr[$k]['laenge'] = '';
             }
             $bistumObj = $ort->getBistum();
             if (is_object($bistumObj)) {
                 $bistum = $bistumObj->getUUID();
                 if (!empty($bistum)) {
                     $ortArr[$k]['bistum'] = $bistum;
                 } else {
                     $ortArr[$k]['bistum'] = '';
                 }
             } else {
                 $ortArr[$k]['bistum'] = '';
             }
         }
     }
     $this->view->assign('ort', ['data' => $ortArr, 'draw' => $draw, 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered]);
     $this->view->assign('bearbeiter', $this->bearbeiterObj->getBearbeiter());
     return $this->view->render();
 }