public function indexAction() { // Check permissions $dumbSim = new SimModel(); $this->_helper->allowed('preinventory_list', $dumbSim); $filters = $this->_mapToModel($this->_getFilterParams(), false); $filters = $this->_mapToFilter($filters); if (isset($filters['subscriptionID'])) { $filters['id'] = $filters['subscriptionID']; } $this->_checkFilterParams($filters, StockFilterFields::getWhiteList()); $filterList = $this->_stockSrv->buildFilterList($filters); $this->_helper->filterNotAllowedFilters('filter_by', $filterList); $filterHelper = $this->_helper->getHelper('filterNotAllowedFilters'); $filterHelper->setThrowExOnNotAllowed(true); $filterHelper->direct('filter_by', $filterList); $params = $this->_getPaginatorParams(); $simList = $this->_stockSrv->listAll($filterList, $params); if ($simList instanceof \Application\Model\ListResultModel) { $this->view->subscriptionData = array(); foreach ($simList as $value) { $subscriptionData = $value->exportData(); $subscriptionData = $this->_mapToSdp($subscriptionData); // Make the data available on the view $this->view->subscriptionData[] = $subscriptionData; } } }
/** * * Check permissions according to the data type and return data * * @param null $perm * @param bool $listOrFilter * @param array $allowed * @return mixed * @throws Application\Exceptions\UnexpectedException * @throws InvalidArgumentException */ protected function _checkAndGetListData($perm = null, $listOrFilter = false, $allowed = array('POST')) { if (!in_array($this->getRequest()->getMethod(), $allowed)) { throw new AppEx\UnexpectedException("Resquest must be " . implode(' or ', $allowed)); } if (!is_null($perm)) { $dumbSim = new Application\Model\SimModel(); $this->_helper->allowed($perm, $dumbSim); } $data = $this->_helper->requestData(); if ($listOrFilter) { if (isset($data['list'])) { if (empty($data['list']) || !is_array($data['list'])) { throw new InvalidArgumentException('Bad Request. Malformed Json. parameter {list} is empty or is not an array'); } } else { if (isset($data['filter'])) { if (!is_array($data['filter'])) { throw new InvalidArgumentException('Bad Request. Malformed Json. parameter {filter} must be an array'); } $data['list'] = $this->_stockSrv->buildFilterList($data['filter']); if ($data['list'] === null) { throw new InvalidArgumentException('Invalid filter parameters'); } $this->_helper->filterNotAllowedFilters('filter_by', $data['list']); } else { throw new InvalidArgumentException('Bad Request. Malformed Json. parameter {list} or {filter} is required'); } } } else { if (empty($data['list']) || !is_array($data['list'])) { throw new InvalidArgumentException('Bad Request. Malformed Json. parameter {list} is empty or is not an array'); } } return $data; }