本文整理匯總了PHP中yii\helpers\Inflector::transliterator方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::transliterator方法的具體用法?PHP Inflector::transliterator怎麽用?PHP Inflector::transliterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\helpers\Inflector
的用法示例。
在下文中一共展示了Inflector::transliterator方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getValue
/**
* @inheritdoc
*/
protected function getValue($event)
{
$isNewSlug = true;
if ($this->attribute !== null) {
$attributes = (array) $this->attribute;
/* @var $owner BaseActiveRecord */
$owner = $this->owner;
if (!$owner->getIsNewRecord() && !empty($owner->{$this->slugAttribute})) {
$isNewSlug = false;
foreach ($attributes as $attribute) {
if ($owner->isAttributeChanged($attribute) && $this->forceUpdate) {
$isNewSlug = true;
break;
}
}
}
if ($isNewSlug) {
$slugParts = [];
foreach ($attributes as $attribute) {
$slugParts[] = $owner->{$attribute};
}
$oldTransliterator = Inflector::$transliterator;
if (isset($this->transliterator)) {
Inflector::$transliterator = $this->transliterator;
}
$slug = Inflector::slug(implode('_', $slugParts));
Inflector::$transliterator = $oldTransliterator;
} else {
$slug = $owner->{$this->slugAttribute};
}
} else {
$slug = parent::getValue($event);
}
if ($this->ensureUnique && $isNewSlug) {
$baseSlug = $slug;
$iteration = 0;
while (!$this->validateSlug($slug)) {
$iteration++;
$slug = $this->generateUniqueSlug($baseSlug, $iteration);
}
}
return $slug;
}