本文整理汇总了PHP中Nette\Object::__get方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::__get方法的具体用法?PHP Object::__get怎么用?PHP Object::__get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Object
的用法示例。
在下文中一共展示了Object::__get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
/**
* Getter
*
* @param string $name
* @return mixed
* @throws MemberAccessException
*/
public function &__get($name)
{
try {
return $this->universalGetValue($name);
} catch (\MemberAccessException $e) {
return parent::__get($name);
}
}
示例2:
public function &__get($name)
{
$val = \strtoupper($name);
if (\defined(self::INFO . $val)) {
$a = $this->getInfo(constant(self::INFO . $val));
return $a;
}
return parent::__get($name);
}
示例3:
/**
* Returns user data value.
* @param string property name
* @return mixed
*/
public function &__get($key)
{
if (parent::__isset($key)) {
return parent::__get($key);
} else {
$data = $this->data->toArray();
return $data[$key];
}
}
示例4:
public function &__get($name)
{
$service = $this->getService($name, false);
if ($service) {
return $service;
}
$object = parent::__get($name);
return $object;
}
示例5: elseif
/**
* @param string
* @return string|NULL
*/
public function &__get($name)
{
if (strtolower($name) === 'info') {
return $this->info;
} elseif (array_key_exists($name, $this->info)) {
return $this->info[$name];
}
return parent::__get($name);
}
示例6: catch
/**
* @param string $name
* @return mixed
*
* @throws \Exception|\Nette\MemberAccessException
*/
public function &__get($name)
{
try {
return parent::__get($name);
} catch (MemberAccessException $e) {
$data = $this->getData();
if (isset($data[$name])) {
return $data[$name];
}
throw $e;
}
}
示例7:
/**
* Returns user data value.
* @param string property name
* @return mixed
*/
public function &__get($key)
{
if (parent::__isset($key)) {
return parent::__get($key);
} else {
return $this->data[$key];
}
}
示例8:
public function &__get($name)
{
if (parent::__isset($name)) {
return parent::__get($name);
}
$value = $this->data->{$name};
if ($value instanceof ActiveRow) {
$value = $this->repository->getReferenced($name, NULL, $value);
}
return $value;
}
示例9:
/**
* Getter proměnných.
* @param mixed $name
* @return mixed
*/
public function &__get($name)
{
return parent::__get($name);
}
示例10: array
/**
* Provides access to shortcuts of page elements defined using property-read
* annotations (eg. `property-read Element $name strategy=value`).
*
* If there is a getter for the value (eg. method `getFoo()` for `$foo` property),
* the getter is used instead.
*
* Definition of a shortcut may include the tag name and required attributes
* values. These are checked then. Eg. `property-read Element $name
* strategy=value, tagName, [attrib=value, another=value]`.
*
* Eventual comment may be separated by a space and a hash: `property-read
* Element $name strategy=value # Now this is a comment.`
*
* @param string $name
* @return mixed
*/
public function &__get($name)
{
$shortcuts = $this->getShortcuts();
if (!parent::__isset($name) && isset($shortcuts[$name])) {
$this->checkState();
$criteria = array('strategy' => $shortcuts[$name][0], 'selector' => $shortcuts[$name][1]);
$expectedTagName = isset($shortcuts[$name][3]) ? $shortcuts[$name][3] : NULL;
$expectedAttribs = isset($shortcuts[$name][4]) ? $shortcuts[$name][4] : NULL;
if ($shortcuts[$name][2]) {
$elements = $this->findElements($criteria['strategy'], $criteria['selector']);
foreach ($elements as $index => $element) {
$shortcutDescription = get_class($this) . '::$' . $name . "[{$index}]";
$this->checkTagNameAndAttributes($element, $shortcutDescription, $expectedTagName, $expectedAttribs);
}
return $elements;
} else {
$element = $this->findElement($criteria['strategy'], $criteria['selector']);
$shortcutDescription = get_class($this) . '::$' . $name;
$this->checkTagNameAndAttributes($element, $shortcutDescription, $expectedTagName, $expectedAttribs);
return $element;
}
} else {
return parent::__get($name);
}
}
示例11: catch
public function &__get($name)
{
if ($this->entity) {
try {
$value = $this->entity->{$name};
return $value;
} catch (MemberAccessException $e) {
}
}
return parent::__get($name);
}
示例12: catch
/**
* Returns property value. Do not call directly.
* Tries to use dynamic getter for protected properties (reflection fields) if getter is not defined.
*
* @param string property name
* @return mixed property value
* @throws MemberAccessException if the property is not defined.
*/
public function &__get($name)
{
try {
$value = parent::__get($name);
return $value;
} catch (MemberAccessException $e) {
if ($this->hasProtectedReflectionField($name)) {
// intentionally not used __isset
$value = $this->{$name};
return $value;
} else {
$class = get_called_class();
throw new MemberAccessException($e->getMessage() . " If you want to use dynamic getter for this property, make sure that property has visibility 'protected'.");
}
}
}
示例13:
/**
* @param string $name
* @return mixed
*/
public function &__get($name)
{
if ($this->isOption($name) && !property_exists($this, $name)) {
return $this->options[$name];
}
return parent::__get($name);
}
示例14: foreach
public function &__get($name)
{
foreach ($this->getExtensions() as $extension) {
/* @var $extension ExtensionObject */
if ($extension->getReflection()->hasProperty($name)) {
$property = $extension->getReflection()->getProperty($name);
if ($property->isPublic() && !$property->isStatic()) {
return $extension->{$name};
}
}
if (ObjectMixin::has($extension, $name)) {
return ObjectMixin::get($extension, $name);
}
}
return parent::__get($name);
}