Contextable

class Nos\Orm_Behaviour_Contextable
Allows a Nos\Orm\Model to be bound to a context.

See also

Multi-Contexts.

Configuration

property Nos\Orm_Behaviour_Contextable::$context_property

Required. Column used to store the item’s context. Its data type must be varchar(25).

property Nos\Orm_Behaviour_Contextable::$default_context

Default context to use if not set when creating an item.

Methods

Nos\Orm_Behaviour_Contextable::get_context()
Returns:The item’s context.

Other

This behaviour extends Model->find().

Add option to where array passed to method: you can use the context key as an alias to search in the column Orm_Behaviour_Contextable::$context_property.

Example

<?php
class Model_Page extends \Nos\Orm\Model
{
        protected static $_behaviours = array(
                'Nos\Orm_Behaviour_Contextable' => array(
                        'events' => array('before_insert'),
                        'context_property' => 'form_context',
                ),
        );
}