当前位置: 首页>>代码示例>>PHP>>正文


PHP BaseModel::__get方法代码示例

本文整理汇总了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);
 }
开发者ID:broofa,项目名称:socipedia,代码行数:7,代码来源:user.php

示例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);
 }
开发者ID:broofa,项目名称:socipedia,代码行数:30,代码来源:entry.php

示例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);
 }
开发者ID:kummerer94,项目名称:corcel,代码行数:15,代码来源:TermTaxonomy.php

示例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);
 }
开发者ID:broofa,项目名称:socipedia,代码行数:16,代码来源:comment.php

示例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;
     }
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:22,代码来源:BaseElementModel.php

示例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);
 }
开发者ID:bahdall,项目名称:karbella_event,代码行数:26,代码来源:StoreProduct.php

示例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;
     }
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:22,代码来源:BaseElementModel.php


注:本文中的BaseModel::__get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。