First, import class file, i.g in config
return array(
'name' => 'My Web Application',
// ...
'import' => array(
'ext.slug-behavior.SlugBehavior',
),
);
Next, attach behavior to model
public function behaviors()
{
return array(
array(
'class' => 'SlugBehavior',
),
);
}
Advanced slug, used translator closure, i.g. Transliterator component:
public function behaviors()
{
return array(
array(
'class' => 'SlugBehavior',
// @link https://github.com/yiiext/transliterator-component
'translator' => array(Yii::app()->trasliterator, 'transliterate'),
),
);
}