本文整理匯總了PHP中Wire::getProperty方法的典型用法代碼示例。如果您正苦於以下問題:PHP Wire::getProperty方法的具體用法?PHP Wire::getProperty怎麽用?PHP Wire::getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Wire
的用法示例。
在下文中一共展示了Wire::getProperty方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _getDot
/**
* Get a property via dot syntax: field.subfield (static)
*
* Static version for internal core use. Use the non-static getDot() instead.
*
* @param string $key
* @param Wire $from The instance you want to pull the value from
* @return null|mixed Returns value if found or null if not
*
*/
public static function _getDot($key, Wire $from)
{
$key = trim($key, '.');
if (strpos($key, '.')) {
// dot present
$keys = explode('.', $key);
// convert to array
$key = array_shift($keys);
// get first item
} else {
// dot not present
$keys = array();
}
if (Wire::getFuel($key) !== null) {
return null;
}
// don't allow API vars to be retrieved this way
if ($from instanceof WireData) {
$value = $from->get($key);
} else {
if ($from instanceof WireArray) {
$value = $from->getProperty($key);
} else {
$value = $from->{$key};
}
}
if (!count($keys)) {
return $value;
}
// final value
if (is_object($value)) {
if (count($keys) > 1) {
$keys = implode('.', $keys);
// convert back to string
if ($value instanceof WireData) {
$value = $value->getDot($keys);
} else {
$value = self::_getDot($keys, $value);
}
} else {
$key = array_shift($keys);
// just one key left, like 'title'
if ($value instanceof WireData) {
$value = $value->get($key);
} else {
if ($value instanceof WireArray) {
if ($key == 'count') {
$value = count($value);
} else {
$a = array();
foreach ($value as $v) {
$a[] = $v->get($key);
}
$value = $a;
}
}
}
}
} else {
// there is a dot property remaining and nothing to send it to
$value = null;
}
return $value;
}