Rev 163 | Rev 207 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
class Conteneur {
protected $parametres = array();
protected $partages = array();
public function __construct(array $parametres = null) {
$this->parametres = is_null($parametres) ? array() : $parametres;
}
public function getParametre($cle) {
$valeur = isset($this->parametres[$cle]) ? $this->parametres[$cle] : Config::get($cle);
return $valeur;
}
public function getParametreTableau($cle) {
$tableau = array();
$parametre = $this->getParametre($cle);
if (empty($parametre) === false) {
$tableauPartiel = explode(',', $parametre);
$tableauPartiel = array_map('trim', $tableauPartiel);
foreach ($tableauPartiel as $champ) {
if (strpos($champ, '=') === false) {
$tableau[] = trim($champ);
} else {
list($cle, $val) = explode('=', $champ);
$tableau[trim($cle)] = trim($val);
}
}
}
return $tableau;
}
public function setParametre($cle, $valeur) {
$this->parametres[$cle] = $valeur;
}
public function getParametresUrl() {
if (!isset($this->partages['Parametres'])){
$this->partages['Parametres'] = new Parametres($this->parametres['parametres'], $this->getBdd());
}
return $this->partages['Parametres'];
}
public function getParametresUrlVerificateur() {
if (!isset($this->partages['ParametresVerificateur'])){
$parametres = $this->getParametresUrl();
$parametresAPI = $this->getParametreTableau('parametresAPI');
$this->partages['ParametresVerificateur'] = new ParametresVerificateur($parametres, $parametresAPI);
}
return $this->partages['ParametresVerificateur'];
}
public function getRessourcesUrl() {
if (!isset($this->partages['Ressources'])){
$this->partages['Ressources'] = new Ressources($this->parametres['ressources']);
}
return $this->partages['Ressources'];
}
public function getRessourcesUrlVerificateur() {
if (!isset($this->partages['RessourcesVerificateur'])){
$ressources = $this->getRessourcesUrl();
$projetsDispo = $this->getParametreTableau('projetsDispo');
$servicesDispo = $this->getParametreTableau('servicesDispo');
$this->partages['RessourcesVerificateur'] = new RessourcesVerificateur($ressources, $projetsDispo, $servicesDispo);
}
return $this->partages['RessourcesVerificateur'];
}
public function getProjet() {
if (!isset($this->partages['Projet'])){
$ressources = $this->getRessourcesUrl();
$projet = new Projet($ressources);
$projet->setCheminBase($this->getParametre('cheminBase'));
$projet->setCheminConfig($this->getParametre('chemin_configurations'));
$projet->setCheminBiblio($this->getParametre('chemin_bibliotheque'));
$projet->initialiser();
$projet->setParamsVerif($this->getParametresUrlVerificateur());
$projet->setRessourcesVerif($this->getRessourcesUrlVerificateur());
$this->partages['Projet'] = $projet;
}
return $this->partages['Projet'];
}
public function getBdd() {
if (!isset($this->partages['Bdd'])){
$this->partages['Bdd'] = new Bdd();
}
return $this->partages['Bdd'];
}
public function getService($classe) {
$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getBdd());
if ($service instanceof NomDetails) {
$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$service->setChampsProjets($this->getParametreTableau('champsProjet'));
$service->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
} else if ($service instanceof NomsListe) {
$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$service->setListeUrl($this->getParametre('listeUrl'));
}
return $service;
}
}
?>