/** * Lists all servicePacks matching a criteria */ public function indexAction() { // Check permissions $sp = new ServicePackModel(); $this->_helper->allowed('list', $sp); // Pagination $params = $this->_getPaginatorParams(); // Filters $filters = $this->_mapToFilter($this->_getFilterParams()); $this->_checkFilterParams($filters, ServicePackFilterFields::getWhiteList()); $filterList = $this->_spSrv->buildFilterList($filters); $this->_helper->filterNotAllowedFilters('filter_by', $filterList); // Search $spList = $this->_spSrv->listAll($filterList, $params); if ($spList) { $list = array(); foreach ($spList->getItems() as $item) { try { $this->_helper->allowed('read', $item); $this->_helper->filterNotAllowedFields('read_field', $item); $list[] = $item; } catch (Exception $e) { // Do nothing } } // Simulate pagination $it = new ArrayIterator($list); $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Iterator($it)); $paginator->setItemCountPerPage($params['count']); // Result $iterator = $paginator->getItemsByPage($params['page']); $this->view->servicePacks = iterator_to_array($iterator, false); } }
/** * Lists all servicePacks matching a criteria */ public function indexAction() { $options = array(); $sp = new ServicePackModel(); $this->_helper->allowed('list', $sp); $params = array(); $filterList = $this->_spSrv->buildFilterList($this->getRequest()->getParams()); if ($filterList !== null) { $this->_helper->filterNotAllowedFilters('filter_by', $filterList); $params['filterList'] = $filterList; } $spList = $this->_spSrv->listAll($params); if ($spList) { $count = $spList->getCount(); $list = array(); foreach ($spList->getItems() as $item) { try { $this->_helper->allowed('read', $item); $list[] = $item; } catch (Exception $e) { $count--; } } // If GET list=names, return only the servicepack names if ($this->_getParam('list') == 'names') { $out = array(); foreach ($list as $item) { $out[] = $item->name; } sort($out); $this->view->data = $out; } else { $this->view->count = $count; $this->view->data = $list; } } }