本文整理汇总了PHP中BaseModel::__get方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::__get方法的具体用法?PHP BaseModel::__get怎么用?PHP BaseModel::__get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::__get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function __get($k)
{
if ($k == 'logName') {
return $this->name;
}
return parent::__get($k);
}
示例2: substr
function __get($k)
{
if ($k == 'editKey') {
return substr($this->auth, 20, 10);
} else {
if ($k == 'stale') {
$cutoff = time() - 365 * (24 * 60 * 60);
$stamp = strtotime($this->updated);
return $stamp < $cutoff;
} else {
if ($k == 'descriptionHtml') {
return hashlinks(linkify(htmlify($this->description)));
} else {
if ($k == 'descriptionSummary') {
return htmlify(substr_replace($this->description, ' ...', 140), false);
} else {
if ($k == 'rssDate') {
// TODO: Is there a better way to handle the timezone? Mysql times are
// GMT and have to be parsed as such.
$oldtz = date_default_timezone_get();
date_default_timezone_set('GMT');
return date('D, d M Y H:i:s T', strtotime($this->updated));
date_default_timezone_set($oldtz);
}
}
}
}
}
return parent::__get($k);
}
示例3: __get
/**
* Magic method to return the meta data like the post original fields
*
* @param string $key
* @return string
*/
public function __get($key)
{
if (!isset($this->{$key})) {
if (isset($this->term->{$key})) {
return $this->term->{$key};
}
}
return parent::__get($key);
}
示例4: strtotime
function __get($k)
{
if ($k == 'friendly_created') {
$ts = strtotime($this->created);
return strftime('%b %e, %Y - %H:%M%P', $ts);
} else {
if ($k == 'from') {
return $this->user->id ? $this->user->name : $this->name;
} else {
if ($k == 'from_link') {
return $this->user->id ? url_to($this->user, 'show') : "";
}
}
}
return parent::__get($k);
}
示例5: __get
/**
* Getter
*
* @param string $name
*
* @throws \Exception
* @return mixed
*/
public function __get($name)
{
// Run through the BaseModel/CModel stuff first
try {
return parent::__get($name);
} catch (\Exception $e) {
// Is $name a field handle?
if ($this->getFieldByHandle($name)) {
return $this->getFieldValue($name);
}
// Fine, throw the exception
throw $e;
}
}
示例6: __get
/**
* Allows to access EAV attributes like normal model attrs.
* e.g $model->eav_some_attribute_name
*
* @todo Optimize, cache.
* @param $name
* @return null
*/
public function __get($name)
{
if (substr($name, 0, 4) === 'eav_') {
if ($this->getIsNewRecord()) {
return null;
}
$attribute = substr($name, 4);
$eavData = $this->getEavAttributes();
if (isset($eavData[$attribute])) {
$value = $eavData[$attribute];
} else {
return null;
}
$attributeModel = StoreAttribute::model()->findByAttributes(array('name' => $attribute));
return $attributeModel->renderValue($value);
}
return parent::__get($name);
}
示例7: catch
/**
* Getter
*
* @param string $name
* @throws \Exception
* @return mixed
*/
function __get($name)
{
// Run through the BaseModel/CModel stuff first
try {
return parent::__get($name);
} catch (\Exception $e) {
// Is $name a field handle?
$field = craft()->fields->getFieldByHandle($name);
if ($field) {
return $this->_getPreppedContentForField($field);
}
// Fine, throw the exception
throw $e;
}
}