2 class MCollectiveAction {
5 public $request = array();
7 function __construct() {
8 if (!isSet($_ENV["MCOLLECTIVE_REQUEST_FILE"])) {
9 throw new Exception("no MCOLLECTIVE_REQUEST_FILE environment variable");
12 if (!isSet($_ENV["MCOLLECTIVE_REPLY_FILE"])) {
13 throw new Exception("no MCOLLECTIVE_REPLY_FILE environment variable");
16 $this->infile = $_ENV["MCOLLECTIVE_REQUEST_FILE"];
17 $this->outfile = $_ENV["MCOLLECTIVE_REPLY_FILE"];
22 function __destruct() {
27 $this->request = json_decode(file_get_contents($this->infile), true);
28 unset($this->request["data"]["process_results"]);
32 file_put_contents($this->outfile, json_encode($this->request["data"]));
35 // prints a line to STDERR that will log at error level in the
36 // mcollectived log file
37 function error($msg) {
38 fwrite(STDERR, "$msg\n");
41 // prints a line to STDOUT that will log at info level in the
42 // mcollectived log file
44 fwrite(STDOUT, "$msg\n");
47 // logs an error message and exits with RPCAborted
53 function __get($property) {
54 if (isSet($this->request[$property])) {
55 return $this->request[$property];
57 throw new Exception("No $property in request");
61 function __set($property, $value) {
62 $this->request["data"][$property] = $value;