Class lispa\amos\core\behaviors\SluggableAmosBehavior

Inheritancelispa\amos\core\behaviors\SluggableAmosBehavior » yii\behaviors\SluggableBehavior » yii\behaviors\AttributeBehavior » yii\base\Behavior » yii\base\Object
Implementsyii\base\Configurable

Class SluggableAmosBehavior

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$attribute string|array|null The attribute or list of attributes whose value will be converted into a slug or null meaning that the $value property will be used to generate a slug. yii\behaviors\SluggableBehavior
$attributes array List of attributes that are to be automatically filled with the value specified via $value. yii\behaviors\AttributeBehavior
$ensureUnique boolean Whether to ensure generated slug value to be unique among owner class records. yii\behaviors\SluggableBehavior
$forceNewSlug boolean You can force new slug generation lispa\amos\core\behaviors\SluggableAmosBehavior
$immutable boolean Whether to generate a new slug if it has already been generated before. yii\behaviors\SluggableBehavior
$owner yii\base\Component|null The owner of this behavior yii\base\Behavior
$skipUpdateOnClean boolean Whether to skip this behavior when the $owner has not been modified yii\behaviors\AttributeBehavior
$slugAttribute string The attribute that will receive the slug value yii\behaviors\SluggableBehavior
$uniqueSlugGenerator callable Slug unique value generator. yii\behaviors\SluggableBehavior
$uniqueValidator array Configuration for slug uniqueness validator. yii\behaviors\SluggableBehavior
$value callable|string|null The value that will be used as a slug. yii\behaviors\SluggableBehavior

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Sets value of an object property. yii\base\Object
__unset() Sets an object property to null. yii\base\Object
attach() Attaches the behavior object to the component. yii\base\Behavior
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
detach() Detaches the behavior object from the component. yii\base\Behavior
evaluateAttributes() Evaluates the attribute value and assigns it to the current attributes. yii\behaviors\AttributeBehavior
events() Declares event handlers for the $owner's events. yii\behaviors\AttributeBehavior
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\behaviors\SluggableBehavior

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
generateSlug() This method is called by getValue() to generate the slug. lispa\amos\core\behaviors\SluggableAmosBehavior
generateUniqueSlug() Generates slug using configured callback or increment of iteration. lispa\amos\core\behaviors\SluggableAmosBehavior
getValue() Returns the value for the current attributes. yii\behaviors\SluggableBehavior
isNewSlugNeeded() Force slug generation lispa\amos\core\behaviors\SluggableAmosBehavior
makeUnique() This method is called by getValue() when $ensureUnique is true to generate the unique slug. yii\behaviors\SluggableBehavior
validateSlug() Checks if given slug value is unique. yii\behaviors\SluggableBehavior

Property Details

$forceNewSlug public property

You can force new slug generation

public boolean $forceNewSlug false

Method Details

generateSlug() protected method

This method is called by getValue() to generate the slug.

You may override it to customize slug generation. The default implementation calls yii\helpers\Inflector::slug() on the input strings concatenated by dashes (-).

protected string generateSlug ( $slugParts )
$slugParts array

An array of strings that should be concatenated and converted to generate the slug value.

return string

The conversion result.

generateUniqueSlug() protected method

Generates slug using configured callback or increment of iteration.

protected string generateUniqueSlug ( $baseSlug, $iteration )
$baseSlug string

Base slug value

$iteration integer

Iteration number

return string

New slug value

throws yii\base\InvalidConfigException
isNewSlugNeeded() protected method

Force slug generation

protected boolean isNewSlugNeeded ( )