private function TripalWebServiceResource::checkValue

3.x TripalWebServiceResource.inc private TripalWebServiceResource::checkValue(&$value)

Checks the value to make sure there are no problems with.

Will also expand any TriaplWebServiceResource by adding their context to this resource and substitute their data in place of the value.

Parameters

$value:

1 call to TripalWebServiceResource::checkValue()
TripalWebServiceResource::addProperty in tripal_ws/includes/TripalWebServiceResource.inc
Adds a new key/value pair to the web serivces response.

File

tripal_ws/includes/TripalWebServiceResource.inc, line 175

Class

TripalWebServiceResource

Code

private function checkValue(&$value) {
  if (is_array($value)) {
    foreach ($value as $k => $v) {
      // If this is an integer then this is a numeric indexed array
      // and we can just check the value.  If not, then make sure the
      // key has been added to the context.
      if (preg_match('/^\d+$/', $k)) {
        $this->checkValue($value[$k]);
      }
      else {
        if ($k != '@id' and $k != '@type') {
          $this->checkKey($k);
        }
        $this->checkValue($value[$k]);
      }
    }
  }
  else {
    // If this is a TripalWebServiceResource then get it's data and use that
    // as the new value.  Also, add in the elements context to this resource.
    if (is_a($value, 'TripalWebServiceResource') or is_subclass_of($value, 'TripalWebServiceResource')) {
      $context = $value->getContext();
      foreach ($context as $k => $v) {
        $this->addContextItem($k, $v);
      }
      $value = $value->getData();
    }
  }
}