Skip to content

spawn behaviors

David Spreekmeester edited this page Dec 2, 2014 · 1 revision

Behaviors

Configurable behaviors

Sluggable

Generates a unique slug.

Advanced Sluggable configuration

Draftable

// online_status default = 0
"Draftable": {
  "default": "draft"
}
// online_status default = 1
"Draftable": {
  "default": "online"
}
// online_status default = 1
"Draftable": {}

Locatable

Custom behaviors

Custom Php behaviors can be spawned as well, as long as they have a relatively simple argument structure. Just configure them in the behaviors section of your Spawner model config, and provide them with the arguments that the Php behavior needs, if any. Json array arguments will be casted to numeric Php arrays, while Json objects will be casted to associative Php arrays.

You can also set the module property for a behavior, so that you can indicate whether the behavior belongs to the app or to Garp.

Default behaviors

Authorable (default)

This spawns database columns author_id and modifier_id. The attached Authorable Php behavior will set these to the appropriate User records, after inserting and updating records through the Garp API.

Timestampable (default)

This spawns database columns created and modified. The attached Timestampable Php behavior will set these to the appropriate datetime values, after inserting and updating records through the Garp API.

HtmlFilterable

For fields of the html type, the HtmlFilterable Php behavior is automatically attached, so that filthy smudgy html is nuked before it could ever reach our precious database.

NotEmpty

For fields that have the (default) required property, the NotEmpty Php behavior is automatically attached, so that illegal content is not allowed to be inserted into the database.

Email

For fields of the email type, the Email Php behavior is automatically attached, so that only valid email addresses can be inserted into the database.

Clone this wiki locally