2016-02-04 22:45:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace manager;
|
|
|
|
|
|
|
|
|
|
|
|
// FORMAT:
|
|
|
|
//
|
|
|
|
// path: "nomModule/nomMethode"
|
|
|
|
// data1: {donnee1}
|
|
|
|
// data2: {donnee2}
|
|
|
|
// ...
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
class ModuleAnswer{
|
|
|
|
|
|
|
|
// Attributs prives utiles (initialisation)
|
|
|
|
private $data;
|
|
|
|
public $error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* CONSTRUCTEUR D'UNE REPONSE DE MODULE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __construct(){
|
2016-02-04 23:07:03 +00:00
|
|
|
$this->data = array();
|
|
|
|
$this->error = ManagerError::Success;
|
2016-02-04 22:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 23:07:03 +00:00
|
|
|
/* AJOUTE UNE DONNEE A LA REPONSE
|
2016-02-04 22:45:03 +00:00
|
|
|
*
|
2016-02-04 23:07:03 +00:00
|
|
|
* @key<String> Le nom de la valeur a ajouter
|
|
|
|
* @value<String> La valeur a ajouter
|
2016-02-04 22:45:03 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-02-04 23:07:03 +00:00
|
|
|
public function append($key, $value){
|
|
|
|
// Ajoute une entree pour la cle @key et de valeur @value
|
|
|
|
$this->data[$key] = $value;
|
2016-02-04 22:45:03 +00:00
|
|
|
|
2016-02-04 23:07:03 +00:00
|
|
|
return $this;
|
|
|
|
}
|
2016-02-04 22:45:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 23:07:03 +00:00
|
|
|
/* AJOUTE TOUTES LES DONNEES A LA REPONSE
|
2016-02-04 22:45:03 +00:00
|
|
|
*
|
2016-02-04 23:07:03 +00:00
|
|
|
* @dataset<Array> Le tableau associatif correspondant a la reponse
|
2016-02-04 22:45:03 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-02-04 23:07:03 +00:00
|
|
|
public function appendAll($dataset){
|
|
|
|
// Ajoute une entree pour la cle @key et de valeur @value
|
|
|
|
$this->data = $dataset;
|
2016-02-04 22:45:03 +00:00
|
|
|
|
2016-02-04 23:07:03 +00:00
|
|
|
return $this;
|
2016-02-04 22:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 23:07:03 +00:00
|
|
|
/* SERIALISATION A PARTIR DES DONNEES
|
2016-02-04 22:45:03 +00:00
|
|
|
*
|
2016-02-04 23:07:03 +00:00
|
|
|
* @return json<String> Retourne les donnees serialisees
|
2016-02-04 22:45:03 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-02-04 23:07:03 +00:00
|
|
|
public function serialize(){
|
2016-02-04 22:45:03 +00:00
|
|
|
|
2016-02-04 23:07:03 +00:00
|
|
|
return json_encode($this->data);
|
2016-02-04 22:45:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|