Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 475 | Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
425 jpm 1
<?php
2
class Conteneur {
3
	protected $parametres = array();
4
	protected $partages = array();
5
 
6
	public function __construct(array $parametres = null) {
7
		$this->parametres = is_null($parametres) ? array() : $parametres;
8
	}
9
 
10
	public function getParametre($cle) {
11
		$valeur = isset($this->parametres[$cle]) ? $this->parametres[$cle] : Config::get($cle);
12
		return $valeur;
13
	}
14
 
15
	public function getParametreTableau($cle) {
16
		$tableau = array();
17
		$parametre = $this->getParametre($cle);
18
		if (empty($parametre) === false) {
19
			$tableauPartiel = explode(',', $parametre);
20
			$tableauPartiel = array_map('trim', $tableauPartiel);
21
			foreach ($tableauPartiel as $champ) {
22
				if (strpos($champ, '=') === false) {
23
					$tableau[] = trim($champ);
24
				} else {
25
					list($cle, $val) = explode('=', $champ);
26
					$tableau[trim($cle)] = trim($val);
27
				}
28
			}
29
		}
30
		return $tableau;
31
	}
32
 
33
	public function setParametre($cle, $valeur) {
34
		$this->parametres[$cle] = $valeur;
35
	}
36
 
37
	public function getOutils() {
38
		if (!isset($this->partages['Outils'])){
39
			$this->partages['Outils'] = new Outils();
40
		}
41
		return $this->partages['Outils'];
42
	}
475 jpm 43
 
441 mathilde 44
	public function getEfloreCommun() {
45
		if (!isset($this->partages['EfloreCommun'])){
478 jpm 46
			$this->partages['EfloreCommun'] = new EfloreCommun($this);
441 mathilde 47
		}
48
		return $this->partages['EfloreCommun'];
49
	}
425 jpm 50
 
51
	public function getMessages() {
52
		if (!isset($this->partages['Messages'])){
53
			$this->partages['Messages'] = new Messages($this->getParametre('-v'));
54
		}
55
		return $this->partages['Messages'];
56
	}
475 jpm 57
 
58
	public function getRestClient() {
59
		if (!isset($this->partages['RestClient'])){
60
			$this->partages['RestClient'] = new RestClient();
61
		}
62
		return $this->partages['RestClient'];
63
	}
478 jpm 64
 
65
	public function getBdd() {
66
		if (!isset($this->partages['Bdd'])){
67
			$this->partages['Bdd'] = new Bdd();
68
		}
69
		return $this->partages['Bdd'];
70
	}
425 jpm 71
}
72
?>