AtkShuttleRelation

An atkShuttleRelation extends the atkManyToManyRelation. The relation shows two lists, one with elements that are currently linked to the master record, and one with available records to choose from. A many-to-many relation uses an intermediate table.
function atkShuttleRelation($name, $link, $destination, $flags=0)
- String $name The name of the relation.
- String $link The full name of the node that is used as intermediairy node.
- String $destination The full name of the node that is the other end of the relation.
- int $flags Flags for the relation.
The intermediairy node is assumed to have 2 attributes that are named after the nodes at both ends of the relation. For example, if node 'project' has a M2M relation with 'activity', then the intermediairy node 'project_activity' is assumed to have an attribute named 'project' and one that is named 'activity'.
If you do not want to use the default primary keys, you can override them by using the functions:
setLocalKey("a_id");
setRemoteKey("b_id");
Example
One person (node A) can have several skills (node B) and the same skill applies to more than one person.
Be careful when using the AF_HIDE flag in the itermediate (A_B) node for the atkManyToOneRelation, in combination with multilanguage fields. When a relation is hidden, the key (a_id) will not be processed and no check on the language is done. This causes the added record to appear multiple times (once for every language), since a_id is not unique in the intermediate table.
Example atkMetaNode
A project has many employees, an employee has many projects
public static function meta(atkMetaPolicy $policy) {
$policy->hasMany('employees', array('through' => 'project_employee'));
}
Example atkNode
An example with non normalized tables.
$rel = $this->add(new atkShuttleRelation( 'surface', 'agx.content_to_surface', 'agx.content_filter_surface', AF_HIDE_ADD | AF_HIDE_LIST | AF_CASCADE_DELETE | AF_HIDE_SEARCH ) );
$rel->setLocalKey('cms_id_product');
$rel->setRemoteKey('cms_id_surface');