Пример #1
0
 /**
  * Internally used to parse the raw response from the service
  * and create an PHP array according to the accept type (JSON, XML)
  */
 public function parseData()
 {
     Yii::trace("Response took " . $this->_info['total_time'] . " seconds:\n" . $this->getRawData(), 'ext.EActiveResource.response');
     switch ($this->_acceptType) {
         case EActiveResourceRequest::APPLICATION_JSON:
             $this->_parsedData = EActiveResourceParser::JSONtoArray($this->getRawData());
             break;
         case EActiveResourceRequest::APPLICATION_XML:
             $this->_parsedData = EActiveResourceParser::XMLtoArray($this->getRawData());
             break;
         case null:
             break;
         default:
             throw new EActiveResourceException('Accept Type ' . $info['content_type'] . ' not implemented!');
     }
 }
 protected function getFormattedResponse($response)
 {
     if (array_key_exists($this->getAcceptType(), $this->autoDetectFormats)) {
         switch ($this->supportedFormats[$this->autoDetectFormats[$this->getAcceptType()]]) {
             case self::APPLICATION_JSON:
                 $response = EActiveResourceParser::JSONtoArray($response);
                 break;
             case self::APPLICATION_XML:
                 $response = EActiveResourceParser::XMLToArray($response);
                 break;
             default:
                 throw new CException('Accept Type ' . $this->getAcceptType() . ' not implemented!');
         }
     }
     return $response;
 }