You are here

class WsDataNode in Web Service Data 7

Hierarchy

Expanded class hierarchy of WsDataNode

1 string reference to 'WsDataNode'
_wsfields_storage_test_field_definitions in modules/wsfields_storage/wsfields_storage.test
Test field definitions

File

modules/ws_services/includes/WsDataNode.inc, line 2

View source
class WsDataNode extends WsData {

  // Returns an array of the content type of the data this processor accepts
  public function accepts() {
    return array(
      'json',
    );
  }

  // Parse the web service response string into a structured array and return the array
  protected function parse($data) {
    $data = $this
      ->unwrap(json_decode($data));
    foreach ($data as $name => $value) {
      if (is_array($value)) {
        foreach ($data[$name] as $lang => $list) {
          if (is_array($list)) {
            foreach ($list as $id => $val) {
              if (is_array($val) and isset($val['value'])) {
                $data[$name][$lang][$id] = $val['value'];
              }
            }
          }
        }
      }
    }
    return $data;
  }
  private function unwrap($data) {
    if (is_object($data)) {
      $data = get_object_vars($data);
    }
    if (is_array($data)) {
      foreach ($data as $k => $v) {
        $data[$k] = $this
          ->unwrap($v);
      }
    }
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WsData::$data public property
WsData::$error protected property
WsData::$languages protected property
WsData::addData public function Add data to an empty object or replace all existing data
WsData::getData public function Retrieve the value for the given data key. 1
WsData::getError public function
WsData::__construct public function
WsDataNode::accepts public function Overrides WsData::accepts
WsDataNode::parse protected function Overrides WsData::parse
WsDataNode::unwrap private function