本文整理汇总了PHP中Resource::offsetGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::offsetGet方法的具体用法?PHP Resource::offsetGet怎么用?PHP Resource::offsetGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource::offsetGet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: offsetGet
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;
}
示例2: offset_get_result
/**
* 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;
}
示例3: offset_get_result
/**
* 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;
}