Rev 216 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
class VersionVerificateur {
private $ressources = null;
private $parametres = null;
private $versions = null;
public function __construct(Ressources $ressources, Parametres $parametres, Versions $versions) {
$this->ressources = $ressources;
$this->parametres = $parametres;
$this->versions = $versions;
}
public function verifier() {
$this->verifierDispoMultiProjetPourService();
$this->verifierExistance();
}
private function verifierDispoMultiProjetPourService() {
$servicesMultiProjet = array('NomDetails');
$classeService = $this->ressources->getServiceClasse();
$versionDemandee = $this->parametres->get('version.projet');
if ($versionDemandee == '*' && in_array($classeService, $servicesMultiProjet) === false) {
$message = "L'affichage de plusieurs versions ne fonctionne que pour les ressources de type /ressources/#id";
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
throw new Exception($message, $code);
}
}
private function verifierExistance() {
$versionDemandee = $this->parametres->get('version.projet');
$versionTrouvee = $this->versions->getVersions();
if (is_numeric($versionDemandee)) {
if (count($versionTrouvee) == 0) {
$projet = $this->ressources->getProjetNom();
$message = "La version '$versionDemandee' n'est pas disponible pour le projet '$projet' !";
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
throw new Exception($message, $code);
}
}
}
}
?>