\QuickApps\Model\BehaviorSluggableBehavior

Sluggable Behavior.

Allows entities to have a unique slug.

Summary

Methods
Properties
Constants
beforeSave()
bindSluggable()
unbindSluggable()
No public properties found
No constants found
_slug()
$_enabled
$_defaultConfig
N/A
No private methods found
No private properties found
N/A

Properties

$_enabled

$_enabled : boolean

Flag.

Type

boolean

$_defaultConfig

$_defaultConfig : array

Default configuration.

  • label: Set to the field name that contains the string from where to generate the slug, or a set of field names to concatenate for generating the slug. title by default.

  • slug: Name of the field name that holds generated slugs. slug by default.

  • separator: Separator char. - by default. e.g.: one-two-three.

  • on: When to generate new slugs. create, update or both (by default).

  • length: Maximum length the generated slug can have. default to 200.

Type

array

Methods

beforeSave()

beforeSave(\Cake\Event\Event $event, \Cake\ORM\Entity $entity, array $options) : boolean

Run before a model is saved, used to set up slug for model.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Cake\ORM\Entity $entity

The entity being saved

array $options

Array of options for the save operation

Throws

\Cake\Error\FatalErrorException

When some of the specified columns in config's "label" is not present in the entity being saved

Returns

boolean —

True if save should proceed, false otherwise

bindSluggable()

bindSluggable() : void

Enables this behavior.

unbindSluggable()

unbindSluggable() : void

Disables this behavior.

_slug()

_slug(string $string, \Cake\ORM\Entity $entity) : string

Generate a slug for the given string and entity.

The generated slug is unique on the whole table.

Parameters

string $string

string from where to generate slug

\Cake\ORM\Entity $entity

The entity for which generate the slug

Returns

string —

Slug for given string