Rev 207 | Rev 216 | 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 getVersions() {
if (!isset($this->partages['Versions'])){
$parametres = $this->getParametresUrl();
$bdd = $this->getBdd();
$projetNom = $this->getProjet()->getNom();
$versions = new Versions($parametres, $bdd, $projetNom);
$this->partages['Versions'] = $versions;
}
return $this->partages['Versions'];
}
public function getBdd() {
if (!isset($this->partages['Bdd'])){
$this->partages['Bdd'] = new Bdd();
}
return $this->partages['Bdd'];
}
public function getNomDao() {
$ressources = $this->getRessourcesUrl();
$parametres = $this->getParametresUrl();
$bdd = $this->getBdd();
$projet = $this->getProjet();
$versions = $this->getVersions();
$nomDao = new NomDAO($ressources, $parametres, $bdd, $projet, $versions);
return $nomDao;
}
public function getNomFormateur() {
$formateur = new NomFormateur();
$formateur->setBdd($this->getBdd());
$formateur->setChampsProjet($this->getParametreTableau('champsProjet'));
$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$formateur->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
return $formateur;
}
public function getService($classe) {
$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur());
if ($service instanceof NomsListe) {
$service->setListeUrl($this->getParametre('listeUrl'));
}
return $service;
}
}
?>