Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 110 | Rev 146 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 110 Rev 145
Line 96... Line 96...
96
	}
96
	}
Line 97... Line 97...
97
 
97
 
98
	private function initialiserProjet() {
98
	private function initialiserProjet() {
99
		$this->chargerNomDuProjet();
99
		$this->chargerNomDuProjet();
-
 
100
		$this->chargerConfigProjet();
100
		$this->chargerConfigProjet();
101
 
101
		// Enregistrement en première position des autoload de la méthode gérant les classes des services
102
		// php5.3 : Enregistrement en première position des autoload de la méthode gérant les classes des services
102
		spl_autoload_register(array($this, 'chargerClasseProjet'), true , true);
103
		spl_autoload_register(array($this, 'chargerClasseProjet'), true , true);
Line 103... Line 104...
103
	}
104
	}
104
 
105
 
Line 122... Line 123...
122
		$chemins[] = $this->cheminCourrant.'commun'.DS;
123
		$chemins[] = $this->cheminCourrant.'commun'.DS;
123
		$chemins[] = Config::get('chemin_bibliotheque');
124
		$chemins[] = Config::get('chemin_bibliotheque');
Line 124... Line 125...
124
 
125
 
125
		foreach ($chemins as $chemin) {
126
		foreach ($chemins as $chemin) {
-
 
127
			$chemin = $chemin.$classe.'.php';
126
			$chemin = $chemin.$classe.'.php';
128
			print_r($chemin);
127
			if (file_exists($chemin)) {
129
			if (file_exists($chemin)) {
128
				require_once $chemin;
130
				require_once $chemin;
129
			}
131
			}
130
		}
132
		}
Line 131... Line 133...
131
	}
133
	}
132
 
134
 
133
	private function avoirRessourceService() {
135
	private function avoirRessourceService() {
-
 
136
		$presenceRessourceService = false;
134
		$presenceRessourceService = false;
137
		$servicesDispo = Outils::recupererTableauConfig('servicesDispo');
135
		$servicesDispo = Outils::recupererTableauConfig('servicesDispo');
138
		if (isset($this->ressources[1])) {
136
		$service = $this->ressources[1];
139
			$service = $this->ressources[1];
-
 
140
			if (in_array($service, $servicesDispo)) {
-
 
141
				$presenceRessourceService = true;
-
 
142
			} else {
-
 
143
				$message = "La service demandé '$service' n'est pas disponible pour le projet {$this->projetNom} !\n".
-
 
144
					"Les services disponibles sont : ".implode(', ', $servicesDispo);
-
 
145
				$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
137
		if (in_array($service, $servicesDispo)) {
146
				throw new Exception($message, $code);
138
			$presenceRessourceService = true;
147
			}
139
		} else {
148
		} else {
140
			$message = "La service demandé '$service' n'est pas disponible pour le projet {$this->projetNom} !\n".
149
			$message = "Vous n'avez pas indiqué de service pour le projet {$this->projetNom} !\n".
141
				"Les services disponibles sont : ".implode(', ', $servicesDispo);
150
				"Les services disponibles sont : ".implode(', ', $servicesDispo);
142
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
151
			$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
143
			throw new Exception($message, $code);
152
			throw new Exception($message, $code);
144
		}
153
		}
Line 154... Line 163...
154
 
163
 
155
		$retour = '';
164
		$retour = '';
156
		$service = null;
165
		$service = null;
157
		foreach ($chemins as $chemin) {
166
		foreach ($chemins as $chemin) {
-
 
167
			if (file_exists($chemin)) {
-
 
168
				if (phpversion() < 5.3) {
-
 
169
					// L'option prepend de spl_autoload_register ne fonctionne pas avant php 5.3
-
 
170
					// TODO : améliorer ce comportement!
-
 
171
					require_once $chemin;
158
			if (file_exists($chemin)) {
172
				}
159
				$service = new $classe($this->getBdd());
173
				$service = new $classe($this->getBdd());
160
				$ressourcesPourService = $this->filtrerRessourcesPourService();
174
				$ressourcesPourService = $this->filtrerRessourcesPourService();
161
				$retour = $service->consulter($ressourcesPourService, $this->parametres);
175
				$retour = $service->consulter($ressourcesPourService, $this->parametres);
162
			}
176
			}