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


PHP Fields::isNativeName方法代码示例

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


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

示例1: setName

 /**
  * Set the field's name
  *
  * @param string $name
  *
  * @return Field $this
  * @throws WireException
  *
  */
 public function setName($name)
 {
     $name = $this->fuel('sanitizer')->fieldName($name);
     if (Fields::isNativeName($name)) {
         throw new WireException("Field may not be named '{$name}' because it is a reserved word");
     }
     if ($this->fuel('fields') && ($f = $this->fuel('fields')->get($name)) && $f->id != $this->id) {
         throw new WireException("Field may not be named '{$name}' because it is already used by another field");
     }
     if (strpos($name, '__') !== false) {
         throw new WireException("Field name '{$name}' may not have double underscores because this usage is reserved by the core");
     }
     if ($this->settings['name'] != $name) {
         if ($this->settings['name'] && $this->settings['flags'] & Field::flagSystem) {
             throw new WireException("You may not change the name of field '{$this->settings['name']}' because it is a system field.");
         }
         $this->trackChange('name');
         if ($this->settings['name']) {
             $this->prevTable = $this->getTable();
         }
         // so that Fields can perform a table rename
     }
     $this->settings['name'] = $name;
     return $this;
 }
开发者ID:posixpascal,项目名称:TrooperCMS,代码行数:34,代码来源:Field.php

示例2: encode

 /**
  * Encodes a sortfield from a fieldname to a signed integer (ID) representing a custom field, or native field name
  *
  * The returned value will be a negative value (or string preceded by a dash) if the sortfield is reversed. 
  *
  * @param string $sortfield
  * @return string|int
  *
  */
 public function encode($sortfield)
 {
     $reverse = false;
     if (substr($sortfield, 0, 1) == '-') {
         $reverse = true;
         $sortfield = substr($sortfield, 1);
     }
     if ($sortfield && !Fields::isNativeName($sortfield)) {
         if ($field = $this->fuel('fields')->get($sortfield)) {
             $sortfield = $field->id;
         } else {
             $sortfield = '';
         }
     }
     if ($sortfield) {
         if ($reverse) {
             $sortfield = "-{$sortfield}";
         }
     } else {
         $sortfield = 'sort';
     }
     return $sortfield;
 }
开发者ID:ryancramerdesign,项目名称:ProcessWire-2.0,代码行数:32,代码来源:PagesSortfields.php


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