Subversion Repositories eFlore/Applications.del

Compare Revisions

Ignore whitespace Rev 2170 → Rev 2171

/branches/v1.11-magnesium/services/modules/0.1/communes/ListeCommunes.php
New file
0,0 → 1,50
<?php
// declare(encoding='UTF-8');
/**
* Web service fournissant une liste de noms de communes correspondants au terme recherché.
*
* @category DEL
* @package Services
* @subpackage Communes
* @version 0.1
* @author Mathias CHOUET <mathias@tela-botanica.org>
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
*/
class ListeCommunes {
 
private $conteneur;
private $navigation;
 
public function __construct(Conteneur $conteneur = null) {
$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
$this->navigation = $conteneur->getNavigation();
}
 
public function consulter() {
$communes = $this->chargerCommunes();
$total = $this->compterCommunes($communes);
$this->navigation->setTotal($total);
$this->navigation->setSansLimite();
 
$resultat = new ResultatService();
$resultat->corps = array('entete' => $this->navigation->getEntete(), 'resultats' => $communes);
return $resultat;
}
 
private function chargerCommunes() {
$urlCelTpl = $this->conteneur->getParametre('urlServiceCelCommune');
$url = $urlCelTpl.$this->navigation->getFiltre('masque.nom');
$restClient = $this->conteneur->getRestClient();
$resultatJson = $restClient->consulter($url);
$resultat = json_decode($resultatJson);
return $resultat;
}
 
private function compterCommunes($communes) {
return count($communes);
}
}