本文整理汇总了PHP中Object::__get方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::__get方法的具体用法?PHP Object::__get怎么用?PHP Object::__get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::__get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
public function &__get($name)
{
if (array_key_exists($name, $this->other)) {
return $this->other[$name];
}
return parent::__get($name);
}
示例2: test___set02
public function test___set02()
{
$item = new Object();
$value = 'bar';
$item->setFoo($value);
$this->assertEquals($value, $item->__get('foo'));
}
示例3: strtolower
function __get($name)
{
$prop = strtolower($name);
if (in_array($prop, self::$Allowed)) {
return isset($this->Properties[$prop]) ? $this->Properties[$prop] : null;
}
return parent::__get($name);
}
示例4: __get
public function __get($key)
{
if (isset($this->_getters[$key])) {
return $this->{$this->_getters[$key]}();
} else {
return parent::__get($key);
}
}
示例5: __get
/**
* Shorthand to retrieve the inaccessible property.
*
* @param string $name The name of the property
* @return mixed The value of the property.
*/
public function __get($name)
{
try {
$property = $this->reflector->getProperty($name);
$property->setAccessible(true);
return $property->getValue($this->object);
} catch (ReflectionException $e) {
return $this->object->__get($name);
}
}
示例6: ucfirst
/**
* Returns property value. Do not call directly.
* support for models [e.g. rolesModel]
* @param string property name
* @return mixed property value
*/
public function &__get($name)
{
$className = ucfirst($name);
if (String::endsWith($className, 'Model') && class_exists($className)) {
if (!isset(self::$models[$className])) {
self::$models[$className] = new $className();
}
return self::$models[$className];
}
return parent::__get($name);
}
示例7: __get
public function __get($name)
{
if ($this->has($name)) {
return $this->get($name);
} else {
return parent::__get($name);
}
}
示例8: __get
/**
* Magic __get method
*
* @param type $name
*/
public function __get($name)
{
if ($this->elements->{$name}) {
return $this->elements->{$name};
}
return parent::__get($name);
}
示例9: __get
/**
* Automatic getter: maps unknown variables to database fields
*
* @param string $varname Name of the database field to get the value of
* @return mixed Value of the given database field
*/
public function __get($varname)
{
// check on inherited getters, setters, and mixins from Object
if (parent::__isset($varname)) {
return parent::__get($varname);
}
if ($this->hasRelationship($varname)) {
return $this->getRelationshipInfo($varname);
}
return $this->getScalar($varname);
}
示例10: update
/**
* Обновляет данные в словаре
* @param $name String: Имя словаря
* @param $data Array: Данные для
*/
public function update($name, $new_data, $condition = array())
{
$name = strtolower($name);
parent::__get("DB")->update($name, $new_data, $condition);
$this->clear_cache($name);
}
示例11: unset
/**
* Fetch connected grapobjects and store in the property.
*
* @param string $property
* @return mixed
*/
function __get($property)
{
if (empty($this->id)) {
return parent::__get($property);
}
$connections = $this->getKnownConnections();
if (array_key_exists($property, $connections) === false) {
// not a (known) connection?
if ($this->_state === 'id_only') {
$fields = Facebook::get($this->id, $this->_apiParameters);
$this->__set($fields);
$this->_state = 'ready';
unset($this->_apiParameters);
if (array_key_exists($property, $fields)) {
return $fields[$property];
}
}
if ($this->_state === 'partial') {
$fields = Facebook::get($this->id);
$this->__set($fields);
$this->_state = 'ready';
if (array_key_exists($property, $fields)) {
return $fields[$property];
}
}
$fields = get_public_vars(get_class($this));
if (array_key_exists($property, $fields)) {
// is the field defined in the class?
$permissions = static::getFieldPermissions(array('id' => $this->id));
if (isset($permissions[$property]) && $permissions[$property] !== 'denied' && in_array($permissions[$property], Facebook::getInstance()->getPermissions()) === false) {
notice('Field "' . $property . '" requires the "' . $permissions[$property] . '" permission', 'Current permissions: ' . quoted_human_implode(' and ', Facebook::getInstance()->getPermissions()));
}
return parent::__get($property);
}
}
try {
// Retrieve a connection
if (isset($connections[$property]['class'])) {
$parameters = array('fields' => call_user_func(array($connections[$property]['class'], 'getAllowedFields')));
} else {
$parameters = array();
}
$method = 'get' . ucfirst($property);
$this->__set(array($property => $this->{$method}($parameters)));
return $this->{$property};
} catch (\Exception $e) {
report_exception($e);
return parent::__get($property);
}
}
示例12: __get
/**
* Get a property
*
* Implement a virtual 'parameters' property to return the parameters object.
*
* @param string $name The property name.
* @return string $value The property value.
*/
public function __get($name)
{
if ($name = 'parameters') {
return $this->getParameters();
}
return parent::__get($name);
}
示例13:
/**
* Returns user data value.
* @param string property name
* @return mixed
*/
public function &__get($key)
{
if ($key === 'name' || $key === 'roles') {
return parent::__get($key);
} else {
return $this->data[$key];
}
}