本文整理汇总了PHP中Nette\ObjectMixin::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectMixin::get方法的具体用法?PHP ObjectMixin::get怎么用?PHP ObjectMixin::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\ObjectMixin
的用法示例。
在下文中一共展示了ObjectMixin::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
public function &__get($key)
{
$column = $this->formatColumnName($key);
if (parent::__isset($column) || !ObjectMixin::has($this, $key)) {
return parent::__get($column);
} else {
return ObjectMixin::get($this, $key);
}
}
示例2: getItemValue
/**
* @param $item
* @param $valueName
* @return mixed
*/
public function getItemValue($item, $valueName)
{
if (isset($this->columnAliases[$valueName])) {
$getterPath = $this->columnAliases[$valueName]->getterPath;
} else {
$getterPath = $valueName;
}
$getters = explode('.', $getterPath);
$value = $item;
foreach ($getters as $getter) {
$value = ObjectMixin::get($value, $getter);
}
return $value;
}
示例3:
/**
* Returns property value. Do not call directly.
* @param string property name
* @return mixed property value
* @throws Nette\MemberAccessException if the property is not defined.
*/
public function &__get($name)
{
return Nette\ObjectMixin::get($this, $name);
}
示例4:
Nette\ObjectMixin::call($this,$name,$args);}function&__get($name){return
Nette\ObjectMixin::get($this,$name);}function
示例5: catch
/**
* Returns property value. Do not call directly.
*
* @param string property name
* @return mixed property value
* @throws MemberAccessException if the property is not defined.
*/
public function &__get($name)
{
try {
$value = ObjectMixin::get($this, $name);
return $value;
} catch (\Nette\MemberAccessException $e) {
$repository = self::em()->getRepository(static::class);
$metadata = $repository->getMetadata();
// je to Column
if ($metadata->hasColumn($name)) {
// data zadana, je tento column inicializovan
if (array_key_exists($name, $this->_data)) {
$value = $this->_data[$name];
return $value;
// PHP work-around (Only variable references should be returned by reference)
} else {
$defaults = $metadata->getDefaults();
// zkusme vratit default (column stale neinicializujeme)
if (array_key_exists($name, $defaults)) {
$value = $defaults[$name];
return $value;
// PHP work-around (Only variable references should be returned by reference)
} else {
$value = NULL;
return $value;
// PHP work-around (Only variable references should be returned by reference)
}
}
} elseif ($metadata->hasAssociation($name)) {
// associace uz byla drive vytvorena, tak ji vratime
if (array_key_exists($name, $this->_associations)) {
$reference = $this->_associations[$name];
return $reference;
}
// associace k tomuto objektu neexistuje, vytvorime ji
$reference = $this->_associations[$name] = $repository->createAssociatedObject($name, $this);
return $reference;
}
// jde o chybu
throw $e;
}
}
示例6: catch
/**
* Returns property value. Do not call directly.
*
* @param string property name
* @return mixed property value
* @throws MemberAccessException if the property is not defined.
*/
public function &__get($name)
{
try {
$value = ObjectMixin::get($this, $name);
return $value;
} catch (\Nette\MemberAccessException $e) {
$config = static::config();
if (!$config->hasColumn($name)) {
if ($config->isAssociation($name)) {
// associace uz byla drive vytvorena, tak ji vratime
if (array_key_exists($name, $this->_associations)) {
$reference = $this->_associations[$name];
return $reference;
}
// jak vidno vytvorena jeste nebyla zjistime o jaky typ se jedna
$reference = $this->_associations[$name] = $config->getAssociation($name)->retrieveReferenced($this);
return $reference;
}
throw $e;
}
if (array_key_exists($name, $this->_data)) {
$value = $this->_data[$name];
return $value;
// PHP work-around (Only variable references should be returned by reference)
} else {
$defaults = $config->getDefaults();
if (array_key_exists($name, $defaults)) {
$value = $defaults[$name];
return $value;
// PHP work-around (Only variable references should be returned by reference)
} else {
$value = NULL;
return $value;
// PHP work-around (Only variable references should be returned by reference)
}
}
}
}
示例7: 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);
}