本文整理汇总了PHP中Zend\Paginator\Paginator::getItemCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getItemCount方法的具体用法?PHP Paginator::getItemCount怎么用?PHP Paginator::getItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Paginator\Paginator
的用法示例。
在下文中一共展示了Paginator::getItemCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listarOcorrenciaAction
public function listarOcorrenciaAction()
{
try {
if ($this->getRequest()->isPost()) {
$limit = json_decode($this->getRequest()->getPost()['limit'], true);
$filters = json_decode($this->getRequest()->getPost()['filters'], true);
$filters = $filters['filters'];
// $filters = array($filters['filters']);
$sortField = $this->getRequest()->getPost()['sortField'];
$sortDirection = $this->getRequest()->getPost()['sortDirection'];
$page = json_decode($this->getRequest()->getPost()['page'], true);
$lotacaoSession = new Container('lotacaoVisibilidade');
$lotacao = $lotacaoSession->lotacaoVisibilidade;
$dados = array('id' => $this->getRequest()->getPost()['id'], 'placaVeiculo' => $this->getRequest()->getPost()['placaVeiculo.placa'], 'lotacaoMacro' => $lotacao);
$ocorrenciaNegocio = $this->getServiceLocator()->get('Frota\\Negocio\\Ocorrencia');
// if ($filtro) {
$retorno = $ocorrenciaNegocio->getRepository()->listarOcorrencia($filters, $dados, $sortField, $sortDirection);
// } else {
// $retorno = $ocorrenciaNegocio->getRepository()->listarOcorrencia($filtro, $dados, $sortField, $sortDirection);
// }
$paginator = new Paginator(new ArrayAdapter($retorno));
$paginator->setCurrentPageNumber($page);
$paginator->setDefaultItemCountPerPage($limit);
$count = $paginator->getItemCount($retorno);
$itemsArray = (array) $paginator->getCurrentItems();
return new JsonModel(array("data" => $itemsArray, "message" => "Ocorrência(s) listada(s) com sucesso", "success" => true, "total" => $count));
}
} catch (ValidacaoException $exc) {
return new JsonModel(array("data" => "", "message" => $exc->getMessage(), "success" => false));
} catch (Exception $exc) {
$logger = $this->getServiceLocator()->get('Zend\\Log');
$logger->err($exc, array("Ocorreu um erro:"));
return new JsonModel(array("data" => "", "message" => $exc->getMessage(), "success" => false));
}
return new JsonModel(array("data" => "", "message" => "Erro na busca dos registros.", "success" => false));
}
示例2: testGetsItemCount
public function testGetsItemCount()
{
$this->assertEquals(101, $this->paginator->getItemCount(range(1, 101)));
$limitIterator = new \LimitIterator(new \ArrayIterator(range(1, 101)));
$this->assertEquals(101, $this->paginator->getItemCount($limitIterator));
}
示例3: listarCnhsVencidasAction
public function listarCnhsVencidasAction()
{
try {
// $scope.cnhsVencidas = [{"matricula": "565", "bairro": "Vincente ires", "cargo": {"codigo": "T", "descricao": "TEMPOR\u00c1RIO"}, "idCargo": "T", "cep": "45454645", "cnh": "123465", "dataValidadeCnh": {"date": "2015-04-20 15:01:30", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "Colonia VP", "municipio": {"id": 2214, "nome": "BONITO ", "uf": {"sigla": "MS", "nome": "MATO GROSSO DO SUL"}}, "uf": {"sigla": "MS", "nome": "MATO GROSSO DO SUL"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "Fulano de Tal", "nomeImpresso": "Fulaninho", "telefone": "6181274017", "tipoCategoriaCnh": "E", "isCnhVencida": true}, {"matricula": "sadasd", "bairro": "asdasd", "cargo": {"codigo": "R", "descricao": "REQUISITADO"}, "idCargo": "R", "cep": "71929000", "cnh": "sadasd", "dataValidadeCnh": {"date": "2015-07-27 15:01:44", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "asdasd", "municipio": {"id": 28, "nome": "BARRA DE S\u00c3O MIGUEL ", "uf": {"sigla": "AL", "nome": "ALAGOAS"}}, "uf": {"sigla": "AL", "nome": "ALAGOAS"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "Rodrigo", "nomeImpresso": "rodrigo", "telefone": "6181274017", "tipoCategoriaCnh": "B", "isCnhVencida": true}, {"matricula": "1152", "bairro": "SAnta Maria", "cargo": {"codigo": "NTC20600", "descricao": "TECNICO DE APOIO ESPECIALIZADO"}, "idCargo": "NTC20600", "cep": "70000000", "cnh": "123134343", "dataValidadeCnh": {"date": "2015-09-26 00:00:00", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "Rua 45", "municipio": {"id": 127, "nome": "ANAM\u00c3 ", "uf": {"sigla": "AM", "nome": "AMAZONAS"}}, "uf": {"sigla": "AM", "nome": "AMAZONAS"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "Joseliton Silva", "nomeImpresso": "Joseliton", "telefone": null, "tipoCategoriaCnh": "B", "isCnhVencida": false}, {"matricula": "1168-1", "bairro": "ARNIQUEIRA", "cargo": {"codigo": "NTC20600", "descricao": "TECNICO DE APOIO ESPECIALIZADO"}, "idCargo": "NTC20600", "cep": "70000000", "cnh": "234234343", "dataValidadeCnh": {"date": "2015-10-15 00:00:00", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "SHIS SUL", "municipio": {"id": 1140, "nome": "ANAJATUBA ", "uf": {"sigla": "MA", "nome": "MARANHAO"}}, "uf": {"sigla": "MA", "nome": "MARANHAO"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "JORGEVAN S. DE PAULA", "nomeImpresso": "JORGEVAN", "telefone": "2343434", "tipoCategoriaCnh": "I", "isCnhVencida": false}];
// $itemsArray = json_decode('[{"matricula": "56w5", "bairro": "Vincente ires", "cargo": {"codigo": "T", "descricao": "TEMPOR\u00c1RIO"}, "idCargo": "T", "cep": "45454645", "cnh": "123465", "dataValidadeCnh": {"date": "2015-04-20 15:01:30", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "Colonia VP", "municipio": {"id": 2214, "nome": "BONITO ", "uf": {"sigla": "MS", "nome": "MATO GROSSO DO SUL"}}, "uf": {"sigla": "MS", "nome": "MATO GROSSO DO SUL"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "Fulano de Tal", "nomeImpresso": "Fulaninho", "telefone": "6181274017", "tipoCategoriaCnh": "E", "isCnhVencida": true}, {"matricula": "sadasd", "bairro": "asdasd", "cargo": {"codigo": "R", "descricao": "REQUISITADO"}, "idCargo": "R", "cep": "71929000", "cnh": "sadasd", "dataValidadeCnh": {"date": "2015-07-27 15:01:44", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "asdasd", "municipio": {"id": 28, "nome": "BARRA DE S\u00c3O MIGUEL ", "uf": {"sigla": "AL", "nome": "ALAGOAS"}}, "uf": {"sigla": "AL", "nome": "ALAGOAS"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "Rodrigo", "nomeImpresso": "rodrigo", "telefone": "6181274017", "tipoCategoriaCnh": "B", "isCnhVencida": true}, {"matricula": "1152", "bairro": "SAnta Maria", "cargo": {"codigo": "NTC20600", "descricao": "TECNICO DE APOIO ESPECIALIZADO"}, "idCargo": "NTC20600", "cep": "70000000", "cnh": "123134343", "dataValidadeCnh": {"date": "2015-09-26 00:00:00", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "Rua 45", "municipio": {"id": 127, "nome": "ANAM\u00c3 ", "uf": {"sigla": "AM", "nome": "AMAZONAS"}}, "uf": {"sigla": "AM", "nome": "AMAZONAS"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "Joseliton Silva", "nomeImpresso": "Joseliton", "telefone": null, "tipoCategoriaCnh": "B", "isCnhVencida": false}, {"matricula": "1168-1", "bairro": "ARNIQUEIRA", "cargo": {"codigo": "NTC20600", "descricao": "TECNICO DE APOIO ESPECIALIZADO"}, "idCargo": "NTC20600", "cep": "70000000", "cnh": "234234343", "dataValidadeCnh": {"date": "2015-10-15 00:00:00", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "endereco": "SHIS SUL", "municipio": {"id": 1140, "nome": "ANAJATUBA ", "uf": {"sigla": "MA", "nome": "MARANHAO"}}, "uf": {"sigla": "MA", "nome": "MARANHAO"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "nome": "JORGEVAN S. DE PAULA", "nomeImpresso": "JORGEVAN", "telefone": "2343434", "tipoCategoriaCnh": "I", "isCnhVencida": false}]');
// return new JsonModel(array("data" => $itemsArray, "message" => "Cnhs vencidas listado(s) com sucesso", "success" => true, "total" => $count));
// $scope.veiculosParaRevisao = [{"placa": "DDD2341", "anoFabricacao": 2012, "chassi": "1212", "combustivel": {"id": 1, "descricao": "GASOLINA"}, "dataDoacao": {"date": "2015-07-15 00:00:00", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "dataCompra": {"date": "2014-07-17 00:00:00", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "lotacao": {"codigo": 410000000, "codigoPai": 400000000, "codigoMacro": null, "descricao": "PROCURADORIA-GERAL DA JUSTICA MILITAR", "sigla": "PGJM"}, "marcaModelo": {"id": 4, "marca": "FIAT", "modelo": "UNO VIVACE 1.0", "kmRevisao": 10000, "mesesRevisao": 12}, "descricaoMarcaModelo": "FIAT\/UNO VIVACE 1.0", "placaMpm": "asd4323", "hodometro": 9543, "proximaKmRevisao": 5000, "proximaDataRevisao": {"date": "2015-01-17 00:00:00", "timezone_type": 3, "timezone": "America\/Sao_Paulo"}, "revisoesFabrica": {}, "kmRevisao": 5000, "mesesRevisao": 6, "status": "2"}];
if ($this->getRequest()->isPost()) {
$limit = json_decode($this->getRequest()->getPost()['limit'], true);
$filtro = $this->getRequest()->getPost()['filtro'];
$page = json_decode($this->getRequest()->getPost()['page'], true);
$lotacaoSession = new Container('lotacaoVisibilidade');
$lotacao = $lotacaoSession->lotacaoVisibilidade;
$dados = array('id' => $this->getRequest()->getPost()['id'], 'nome' => $this->getRequest()->getPost()['nome'], 'lotacao' => $lotacao);
$motoristaNegocio = $this->getServiceLocator()->get('Frota\\Negocio\\Motorista');
$retorno = $motoristaNegocio->getRepository()->listarCnhsVencidas($filtro, $dados);
$paginator = new Paginator(new ArrayAdapter($retorno));
$paginator->setCurrentPageNumber($page);
$paginator->setDefaultItemCountPerPage($limit);
$count = $paginator->getItemCount($retorno);
$itemsArray = (array) $paginator->getCurrentItems();
return new JsonModel(array("data" => $itemsArray, "message" => "Cnhs vencidas listado(s) com sucesso", "success" => true, "total" => $count));
}
} catch (ValidacaoException $exc) {
return new JsonModel(array("data" => "", "message" => $exc->getMessage(), "success" => false));
} catch (Exception $exc) {
$logger = $this->getServiceLocator()->get('Zend\\Log');
$logger->err($exc, array("Ocorreu um erro:"));
return new JsonModel(array("data" => "", "message" => $exc->getMessage(), "success" => false));
}
return new JsonModel(array("data" => "", "message" => "Erro na busca dos registros.", "success" => false));
}