/**
  * Check if collection field value exists
  *
  * @param  string $index
  * @return bool
  */
 public function offsetExists($index)
 {
     if (!($exists = parent::offsetExists($index))) {
         if (isset($this->{$index})) {
             return true;
         }
     }
     return $exists;
 }
Beispiel #2
0
 public function offsetGet($name)
 {
     if (parent::offsetExists($name)) {
         return parent::offsetGet($name);
     }
     $resource = null;
     if (isset($this->static[$name])) {
         $resource = $this->static[$name];
     } elseif (isset($this->resources[$name])) {
         $resource = $this->resources[$name];
     }
     if ($resource === null) {
         throw new \OutOfBoundsException();
     }
     $resource->__parent = $this;
     $resource->__name = $name;
     return $resource;
 }
 /**
  * Get record field value as a record result
  *
  * @param  string $field
  * @return mixed
  **/
 public function offset_get_result($field)
 {
     $data_links = null;
     if (isset($this->links['*'])) {
         $data_links = $this->links['*'];
     } else {
         if (isset($this->links[$field]['links'])) {
             $data_links = $this->links[$field]['links'];
         }
     }
     $data_value = parent::offsetExists($field) ? parent::offsetGet($field) : null;
     if (is_array($data_value) && !empty($data_value)) {
         $collection = isset($this->headers['$collection']) ? $this->headers['$collection'] : null;
         $data_record = new Record(array('$url' => $this->link_url($field), '$data' => $data_value, '$links' => $data_links, '$collection' => $collection));
         $this->offsetSet($field, $data_record);
         return $data_record;
     } else {
         if (!isset($data_value)) {
             // Find object within array by id
             $data = $this->getArrayCopy();
             foreach ($data as $data_val) {
                 if (isset($data_val['id']) && $data_val['id'] === $field) {
                     $data_value = $data_val;
                     break;
                 }
             }
         }
     }
     return $data_value;
 }
Beispiel #4
0
 /**
  * Get record field value as a record result
  *
  * @param  string $field
  * @return mixed
  **/
 public function offset_get_result($field)
 {
     $data_links = null;
     if (isset($this->links['*'])) {
         $data_links = $this->links['*'];
     } else {
         if (isset($this->links[$field]['links'])) {
             $data_links = $this->links[$field]['links'];
         }
     }
     $data_value = parent::offsetExists($field) ? parent::offsetGet($field) : null;
     if (is_array($data_value) && !empty($data_value)) {
         $collection = isset($this->headers['$collection']) ? $this->headers['$collection'] : null;
         $data_record = new Record(array('$url' => $this->link_url($field), '$data' => $data_value, '$links' => $data_links, '$collection' => $collection));
         $this->offsetSet($field, $data_record);
         return $data_record;
     }
     return $data_value;
 }