本文整理汇总了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;
}
示例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;
}