Ref
Categories
Component ID
2418459
Component name
Ref
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
API module for creating relationship between entities.
Dependencies:
Architecture:
Each entity type with ref enabled will have capability of creating relation to any other entity in the system. Data belong to that relationship is called relationship attribute. Relationship attributes have schema-less structure with attribute key is represented by dot notation string.
Usage:
// Create a relationship
ref('node', $node)->create('user', $user, array(
'foo' => array(
'bar' => array(
'foo' => array(
'foo' => 'bar',
'bar' => 'foo'
)
)
)
))->save();
// Find relationships by an attribute
ref('node', $node)->find('user', $user)->attr('foo.bar.foo.foo', 'bar')->result();
// Remove relationships with explicit targeted entity type and an attribute
ref('user', $user)->find('node')->attr('foo.bar', 10, '>')->remove();
// Update a relationship
$ref = ref_load('node', $ref_id);
if (is_object($ref)) {
$ref->setAttr(array(
'address' => array(
'city' => 'Brisbane'
)
))->save();
}
