/** * This method processes the models and returns the status. * * @access public * @param BT\Exchange $exchange the exchange given to process * @return integer the status code */ public function process(BT\Exchange $exchange) { $body = $exchange->getIn()->getBody(); if ($body instanceof Common\Mutable\HashMap) { $writer = new Config\JSON\Writer($body); $writer->config($this->policy->toDictionary()); $writer->export($exchange->getOut()); return BT\Task\Status::SUCCESS; } return BT\Task\Status::FAILED; }
/** * This method converts an associated array to either a SimpleXMLElement or an XML formatted * string depending on the second parameter. * * @access public * @static * @param array $array the associated array to be converted * @param boolean $as_string whether to return a string * @return mixed either a SimpleXMLElement or an XML * formatted string */ public static function encode(array $array, $as_string = false) { $writer = new Config\JSON\Writer($array); $contents = $writer->render(); if ($as_string) { return $contents; } $XML = new static($contents); return $XML; }