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


PHP Wire::get方法代码示例

本文整理汇总了PHP中Wire::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Wire::get方法的具体用法?PHP Wire::get怎么用?PHP Wire::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wire的用法示例。


在下文中一共展示了Wire::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getDot

 /**
  * Get a property via dot syntax: field.subfield (static)
  *
  * Static version for internal core use. Use the non-static getDot() instead.
  *
  * @param string $key 
  * @param Wire $from The instance you want to pull the value from
  * @return null|mixed Returns value if found or null if not
  *
  */
 public static function _getDot($key, Wire $from)
 {
     $key = trim($key, '.');
     if (strpos($key, '.')) {
         // dot present
         $keys = explode('.', $key);
         // convert to array
         $key = array_shift($keys);
         // get first item
     } else {
         // dot not present
         $keys = array();
     }
     if (Wire::getFuel($key) !== null) {
         return null;
     }
     // don't allow API vars to be retrieved this way
     if ($from instanceof WireData) {
         $value = $from->get($key);
     } else {
         if ($from instanceof WireArray) {
             $value = $from->getProperty($key);
         } else {
             $value = $from->{$key};
         }
     }
     if (!count($keys)) {
         return $value;
     }
     // final value
     if (is_object($value)) {
         if (count($keys) > 1) {
             $keys = implode('.', $keys);
             // convert back to string
             if ($value instanceof WireData) {
                 $value = $value->getDot($keys);
             } else {
                 $value = self::_getDot($keys, $value);
             }
         } else {
             $key = array_shift($keys);
             // just one key left, like 'title'
             if ($value instanceof WireData) {
                 $value = $value->get($key);
             } else {
                 if ($value instanceof WireArray) {
                     if ($key == 'count') {
                         $value = count($value);
                     } else {
                         $a = array();
                         foreach ($value as $v) {
                             $a[] = $v->get($key);
                         }
                         $value = $a;
                     }
                 }
             }
         }
     } else {
         // there is a dot property remaining and nothing to send it to
         $value = null;
     }
     return $value;
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:74,代码来源:WireData.php

示例2: objectToString

 /**
  * Render an object to a string
  * 
  * @param Wire|object $value
  * @return string
  * 
  */
 protected function objectToString($value)
 {
     if ($value instanceof WireArray && !$value->count()) {
         return '';
     }
     if ($value instanceof Page) {
         return $value->get('title|name');
     }
     if ($value instanceof Pagefiles || $value instanceof Pagefile) {
         $out = $this->renderInputfieldValue($value);
     } else {
         $className = get_class($value);
         $out = (string) $value;
         if ($out === $className) {
             // just the class name probably isn't useful here, see if we can do do something else with it
             $this->renderIsUseless = true;
         }
     }
     return $out;
 }
开发者ID:Smubs,项目名称:ProcessWire,代码行数:27,代码来源:MarkupFieldtype.php

示例3: objectToString

 /**
  * Render an object to a string
  * 
  * @param Wire|object $value
  * @return string
  * 
  */
 protected function objectToString($value)
 {
     if ($value instanceof Page) {
         return $value->get('title|name');
     }
     $className = get_class($value);
     $out = (string) $value;
     if ($out === $className) {
         // just the class name probably isn't useful here, see if we can do do something else with it
         $this->renderIsUseless = true;
     }
     return $out;
 }
开发者ID:Rizsti,项目名称:Processwire_Compatibility,代码行数:20,代码来源:MarkupFieldtype.php


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