public function indexAction() { $dumpOrg = new OrgAggregatorModel(); $this->_helper->allowed('list', $dumpOrg); $params = $this->_getPaginatorParams(); $filters = $this->_getFilterParams(); $this->_checkFilterParams($filters, AggregatorFilterFields::getWhiteList()); $filters['type'] = OrgAggregatorModel::ORG_TYPE; $filterList = $this->_orgSrv->buildFilterList($filters); $filterHelper = $this->_helper->getHelper('filterNotAllowedFilters'); $filterHelper->setThrowExOnNotAllowed(true); $filterHelper->direct('filter_by', $filterList); $aggregatorList = $this->_orgSrv->listAll(OrgAggregatorModel::ORG_TYPE, $params); $orgs = array(); if (!$aggregatorList instanceof Application\Model\ListResultModel) { throw new AppEx\UnexpectedException('No list returned'); } $items = $aggregatorList->getItems(); // Pagination $items = array_slice($items, $params['startIndex'], $params['maxBatchSize']); foreach ($items as $item) { $this->_helper->filterNotAllowedFields('read_field', $item); $org = $this->_mapToSdp($item->exportData()); $orgs[] = array('status' => $org['status'], 'name' => $org['name'], 'endCustomerID' => $org['endCustomerID']); } // Make data available on the view $this->view->endCustomerData = $orgs; }
/** * Builds a filter list based on params. * @param array $params * @return App_ListFilter | null */ public function buildFilterList(array $params) { if (!isset($params['type']) || !in_array($params['type'], array(OrgMasterModel::ORG_TYPE, OrgServiceProviderModel::ORG_TYPE, OrgCustomerModel::ORG_TYPE, OrgAggregatorModel::ORG_TYPE))) { return; } $orgType = $params['type']; unset($params['type']); if ($orgType === OrgServiceProviderModel::ORG_TYPE && \App::getOrgUserLogged()->getType() === OrgServiceProviderModel::ORG_TYPE) { if (!isset($params[ServiceProviderFilterFields::SERVICE_PROVIDER_ID_FOR_COMMERCIALS])) { $params[ServiceProviderFilterFields::SERVICE_PROVIDER_ID_FOR_COMMERCIALS] = \App::getOrgUserLogged()->id; } } $factory = new \App_ListFilter_FilterFactory(); $filterFieldsMap = array(OrgMasterModel::ORG_TYPE => '\\Application\\Model\\Filter\\Organization\\MasterFilterFields', OrgServiceProviderModel::ORG_TYPE => '\\Application\\Model\\Filter\\Organization\\ServiceProviderFilterFields', OrgCustomerModel::ORG_TYPE => '\\Application\\Model\\Filter\\Organization\\CustomerFilterFields', OrgAggregatorModel::ORG_TYPE => '\\Application\\Model\\Filter\\Organization\\AggregatorFilterFields'); $filterFieldsValidatorsMap = array(OrgMasterModel::ORG_TYPE => MasterFilterFields::getValidatorSpec(), OrgServiceProviderModel::ORG_TYPE => ServiceProviderFilterFields::getValidatorSpec(), OrgCustomerModel::ORG_TYPE => CustomerFilterFields::getValidatorSpec(), OrgAggregatorModel::ORG_TYPE => AggregatorFilterFields::getValidatorSpec()); if (isset($filterFieldsMap[$orgType])) { $class = $filterFieldsMap[$orgType]; $factory->setWhiteList($class::getWhiteList()); } $filterList = $factory->constructFilter($params); if (isset($class)) { $filterList->setResourceId($class::getResourceId()); } \App::log()->debug('Unused filters [' . implode(',', $factory->getUnusedList()) . ']'); $filterList->setValidators($filterFieldsValidatorsMap[$orgType]); return $filterList->isValid() ? $filterList : null; }