Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 478 | Rev 880 | 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 getOutils() {
                if (!isset($this->partages['Outils'])){
                        $this->partages['Outils'] = new Outils();
                }
                return $this->partages['Outils'];
        }

        public function getEfloreCommun() {
                if (!isset($this->partages['EfloreCommun'])){
                        $this->partages['EfloreCommun'] = new EfloreCommun($this);
                }
                return $this->partages['EfloreCommun'];
        }

        public function getMessages() {
                if (!isset($this->partages['Messages'])){
                        $this->partages['Messages'] = new Messages($this->getParametre('-v'));
                }
                return $this->partages['Messages'];
        }

        public function getGenerateurNomSciHtml() {
                if (!isset($this->partages['GenerateurNomSciHtml'])){
                        $this->partages['GenerateurNomSciHtml'] = new GenerateurNomSciHtml();
                }
                return $this->partages['GenerateurNomSciHtml'];
        }

        public function getRestClient() {
                if (!isset($this->partages['RestClient'])){
                        $this->partages['RestClient'] = new RestClient();
                }
                return $this->partages['RestClient'];
        }

        public function getBdd() {
                if (!isset($this->partages['Bdd'])){
                        $this->partages['Bdd'] = new Bdd();
                }
                return $this->partages['Bdd'];
        }
}
?>