Virtualname

class Nos\Orm_Behaviour_Virtualname
Adds a slug property to item.
The slug is automatically generated based on the title_property of the model if it is not specified.
If Orm_Behaviour_Virtualname::$unique is set, ->save() method can throw an Exception if slug already in use.

Configuration

property Nos\Orm_Behaviour_Virtualname::$virtual_name_property

Required. Column used to store the slug.

property Nos\Orm_Behaviour_Virtualname::$unique

true, false or 'context' if uniqueness must be checked by context.

Methods

Nos\Orm_Behaviour_Virtualname::virtual_name()
Returns:Item slug.
Nos\Orm_Behaviour_Virtualname::friendly_slug($slug)
Parameters:
  • $slug (string) – A slug to clean.
Returns:

A clean slug, lowercase, without forbidden characters.

Example

<?php
class Model_Monkey extends \Nos\Orm\Model
{
        protected static $_behaviours = array(
                'Nos\Orm_Behaviour_Virtualname' => array(
                        'events' => array('before_save', 'after_save'),
                        'virtual_name_property' => 'monk_virtual_name',
                ),
        );
}
Read the Docs v: 0.2
Versions
latest
chiba.2
chiba.1
0.2
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.