Extends Nos\Orm_Behaviour_Contextable.It adds the ability to twin together different items with different contexts.See also
See also
Nos\Orm_Behaviour_Contextable for configuration and methods.
Required. Column used to store the common ID between twinned items. Data type must be int.
Required. Column used to store if the item is the main item among twin items. Data type must be boolean.
Removes all items twinned to the current item, including the current item itself.
Returns: | True if item is the main among twin items. |
---|
Parameters: |
|
---|---|
Returns: | A twinned item, or an array of twinned items, null or array() if none. |
Returns: | The main item among the twins. |
---|
Alias for ->find_context('main').
Parameters: |
|
---|---|
Returns: | Array of twin items, current item exclude. |
Returns: | Array of all twinned contexts, including the one of the current item. |
---|
Parameters: |
|
---|---|
Returns: | Array of all twinned contexts ID, excluding the one of the current item. |
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Twinnable' => array(
'events' => array('before_insert', 'after_insert', 'before_save', 'after_delete', 'change_parent'),
'context_property' => 'page_context',
'common_id_property' => 'page_context_common_id',
'is_main_property' => 'page_context_is_main',
'invariant_fields' => array(),
),
);
}