6,6 → 6,7 |
private $cheminBase = ''; |
private $cheminConfig = ''; |
private $cheminBiblio = ''; |
private $serviceGenerique = ''; |
|
public function __construct(Ressources $ressources) { |
$this->ressources = $ressources; |
31,6 → 32,10 |
$this->ressourcesVerif = $ressourcesVerificateur; |
} |
|
public function setServiceGenerique($generique) { |
$this->serviceGenerique = $generique; |
} |
|
public function initialiser() { |
$this->chargerConfig(); |
// php5.3 : Enregistrement en première position des autoload de la méthode gérant les classes des services |
44,7 → 49,6 |
private function chargerConfig() { |
$projet = $this->getNom(); |
$chemin = $this->cheminConfig."config_$projet.ini"; |
|
Config::charger($chemin); |
} |
|
52,6 → 56,10 |
return $this->ressources->getProjetNom(); |
} |
|
public function getClasse() { |
return $this->ressources->getServiceClasse().ucfirst($this->getNom()); |
} |
|
private function chargerClasseProjet($classe) { |
if (class_exists($classe)) { |
return null; |
61,6 → 69,7 |
$chemins[] = $this->cheminBase.$this->getNom().DS; |
$chemins[] = $this->cheminBase.'commun'.DS; |
$chemins[] = $this->cheminBiblio; |
$chemins[] = $this->cheminBiblio.'generique'.DS; |
$chemins[] = $this->cheminBiblio.'interfaces'.DS; |
$chemins[] = $this->cheminBiblio.'nom'.DS; |
$chemins[] = $this->cheminBiblio.'nom'.DS.'decorateurs'.DS; |
73,52 → 82,6 |
} |
} |
|
public function getServiceClasseNom() { |
$classeNom = ''; |
if ($this->ressources->getNombre() == 2) { |
if ($this->ressources->getServiceNom() == 'noms') { |
$classeNom = 'NomsListe'; |
} else if ($this->ressources->getServiceNom() == 'taxons') { |
$classeNom = 'TaxonsListe'; |
} |
|
} else if ($this->ressources->getNombre() == 3) { |
$position3 = $this->ressources->getParPosition(2); |
if ($this->ressources->etreId($position3)) { |
if ($this->ressources->getServiceNom() == 'noms') { |
$classeNom = 'NomDetails'; |
} else if ($this->ressources->getServiceNom() == 'taxons') { |
$classeNom = 'TaxonDetails'; |
} |
} |
} else if ($this->ressources->getNombre() == 4) { |
$position3 = $this->ressources->getParPosition(2); |
$position4 = $this->ressources->getParPosition(3); |
if ($this->ressources->etreStats($position3)) { |
if ($this->ressources->etreTypeDeStats($position4)) { |
$classeNom = 'NomsStats'.ucfirst($position4); |
} |
} else if ($this->ressources->etreId($position3)) { |
if ($this->ressources->etreRelations($position4)) { |
$classeNom = 'NomRelations'; |
} |
} |
} else if ($this->ressources->getNombre() == 5) { |
$position3 = $this->ressources->getParPosition(2); |
$position4 = $this->ressources->getParPosition(3); |
$position5 = $this->ressources->getParPosition(4); |
if ($this->ressources->etreId($position3)) { |
if ($this->ressources->etreRelations($position4)) { |
if ($this->ressources->etreTypeDeRelations($position5)) { |
$classeNom = 'NomRelations'.ucfirst($position5); |
} |
} |
} |
} |
$classeNomProjet = $classeNom.'Generique';//.ucfirst($this->getNom()); |
return $classeNomProjet; |
} |
|
public function verifier() { |
$this->paramsVerif->verifier(); |
$this->ressourcesVerif->verifier(); |
126,12 → 89,21 |
} |
|
private function verifierExistanceServiceClasse() { |
$classe = $this->getClasse(); |
$existe = $this->verifierExistanceClasseDuProjet($classe); |
|
if ($existe === false) { |
$service = $this->ressources->getServiceNom(); |
$classe = $this->getServiceClasseNom(); |
$projet = $this->getNom(); |
$message = "La classe du service demandé '$service' n'existe pas dans le projet '$projet' !"; |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; |
throw new Exception($message, $code); |
} |
} |
|
private function verifierExistanceClasseDuProjet($classe) { |
$chemins = array(); |
$chemins[] = $this->cheminBase.$projet.DS.$classe.'.php'; |
$chemins[] = $this->cheminBase.$this->getNom().DS.$classe.'.php'; |
$chemins[] = $this->cheminBase.'commun'.DS.$classe.'.php'; |
|
$existe = false; |
141,11 → 113,14 |
break; |
} |
} |
if ($existe === false) { |
$message = "La classe '$classe' du service demandé '$service' n'existe pas dans le projet '$projet' !"; |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; |
throw new Exception($message, $code); |
return $existe; |
} |
|
public function consulter() { |
$serviceNom = $this->getClasse(); |
$service = new $serviceNom($this->serviceGenerique); |
$retour = $service->consulter(); |
return $retour; |
} |
|
} |