Public Member Functions

ObjectRelation Class Reference

Object relations model. More...

Inheritance diagram for ObjectRelation:
BEAppModel AppModel

List of all members.

Public Member Functions

 afterFind ($results)
 createRelation ($id, $objectId, $switch, $priority, $bidirectional=true, $params=array())
 Create relation between objects.
 createRelationAndInverse ($id, $objectId, $switch, $inverseSwitch=null, $priority=null, $params=array())
 Create direct and inverse relation using $switch and $inverseSwitch names.
 deleteRelation ($id, $objectId=null, $switch=null, $bidirectional=true)
 delete relation between objects
 deleteRelationAndInverse ($id, $objectId=null, $switch=null)
 Delete relations If $objectId is defined remove relations between $id and $objectId else remove all relations of $id If $switch is defined remove relation $switch and its inverse.
 deleteObjectRelation ($id, $switch, $inverseSwitch=null)
 delete a specific relation to an object
 updateRelationPriority ($id, $objectId, $switch, $priority)
 updateRelationParams ($id, $objectId, $switch, $params=array())
 Updates parameters of a relation between objects.
 updateRelation ($id, $objectId, $switch, array $set)
 Update a relation using an array of fields to update $set can contains 'params' and 'priority' If $set['params'] is defined then params is also updated in the inverse relation.
 relationExists ($id, $objectId, $switch)
 Check object relation existence.
 relationPriority ($id, $objectId, $switch)
 Get current priority for a specific relation.
 relationParams ($id, $objectId, $switch, $assoc=true)
 Get current parameters for a specific relation.
 availableRelations ($objectType)
 Returns array of available relations for an $objectType relations with 'hidden' => true are excluded If 'inverse' relation is defined ('inverse' => 'inverseName'), then types on 'right' side will have 'inverseName' relation.
 countRelations (array $objects, array $options)
 passed an array of BEdita objects add 'num_of_relations_name' key with the number of each relations passed in options applied to objects
 isValid ($name, $objectType)
 Check if relation $name is valid for object type $objectType Return true if it's valid, false otherwise.
 inverseOf ($name, $relations=array())
 Return the inverse name of relation named $name Passing an array of relation ($relation) it searches inside that else search in all relations.

Detailed Description

Object relations model.

Definition at line 26 of file object_relation.php.


Member Function Documentation

ObjectRelation::availableRelations ( objectType  ) 

Returns array of available relations for an $objectType relations with 'hidden' => true are excluded If 'inverse' relation is defined ('inverse' => 'inverseName'), then types on 'right' side will have 'inverseName' relation.

array returned is like array('relation_name' => 'relation label', ...)

Parameters:
string|int $objectType Object type name or object type id
Returns:
array

Definition at line 359 of file object_relation.php.

References BeLib::getObject().

ObjectRelation::countRelations ( array $  objects,
array $  options 
)

passed an array of BEdita objects add 'num_of_relations_name' key with the number of each relations passed in options applied to objects

Parameters:
array $objects
array $options list of options accepted

  • relations: array of relation name as array('attach', 'seealso')
Returns:
array $objects

Definition at line 414 of file object_relation.php.

ObjectRelation::createRelation ( id,
objectId,
switch,
priority,
bidirectional = true,
params = array() 
)

Create relation between objects.

TODO: sql query, not working with cake ->save() .. why??

cake->save() doesn't work beacuse of table structure. It should be id primary key, object_id, related_object_id, switch, priority)

Parameters:
int $id
int $objectId
string $switch
int $priority
Returns:
unknown, $this->query() output - false on error

Definition at line 58 of file object_relation.php.

ObjectRelation::createRelationAndInverse ( id,
objectId,
switch,
inverseSwitch = null,
priority = null,
params = array() 
)

Create direct and inverse relation using $switch and $inverseSwitch names.

Parameters:
int $id, left relation element id
int $objectId, right relation element id
string $switch, direct name
int $priority
string $inverseSwitch, inverse name

Definition at line 81 of file object_relation.php.

ObjectRelation::deleteObjectRelation ( id,
switch,
inverseSwitch = null 
)

delete a specific relation to an object

Parameters:
int $id - object id
string $switch - relation direct name
string $inverseSwitch - relation inverse name, null if name ids the same
Returns:
bool

Definition at line 190 of file object_relation.php.

ObjectRelation::deleteRelation ( id,
objectId = null,
switch = null,
bidirectional = true 
)

delete relation between objects

Parameters:
int $id
int $objectId
string $switch
bool $bidirectional
Returns:
bool

Definition at line 123 of file object_relation.php.

ObjectRelation::deleteRelationAndInverse ( id,
objectId = null,
switch = null 
)

Delete relations If $objectId is defined remove relations between $id and $objectId else remove all relations of $id If $switch is defined remove relation $switch and its inverse.

Parameters:
int $id
int $objectId
string $switch
bool $bidirectional
Returns:
bool

Definition at line 156 of file object_relation.php.

References inverseOf().

ObjectRelation::inverseOf ( name,
relations = array() 
)

Return the inverse name of relation named $name Passing an array of relation ($relation) it searches inside that else search in all relations.

Parameters:
string $name a direct or inverse relation name
array $relations an array of relations on which search
Returns:
string|false

Definition at line 479 of file object_relation.php.

References BeLib::getObject().

Referenced by deleteRelationAndInverse(), and updateRelation().

ObjectRelation::isValid ( name,
objectType 
)

Check if relation $name is valid for object type $objectType Return true if it's valid, false otherwise.

Parameters:
string $name the relation name (it can be also the inverse name)
string $objectType the object type name
Returns:
boolean

Definition at line 435 of file object_relation.php.

References BeLib::getObject().

ObjectRelation::relationExists ( id,
objectId,
switch 
)

Check object relation existence.

Parameters:
int $id
int $objectId
string $switch
Returns:
true if relation exists, false otherwise

Definition at line 305 of file object_relation.php.

ObjectRelation::relationParams ( id,
objectId,
switch,
assoc = true 
)

Get current parameters for a specific relation.

Parameters:
int $id
int $objectId
string $switch
bool $assoc true to return an associative array, false to return an object (default: true)
Returns:
parameters as an associative array or object, or false if field is NULL or relation missing

Definition at line 338 of file object_relation.php.

ObjectRelation::relationPriority ( id,
objectId,
switch 
)

Get current priority for a specific relation.

Parameters:
int $id
int $objectId
string $switch
Returns:
priority value or false if field is NULL or relation missing

Definition at line 321 of file object_relation.php.

ObjectRelation::updateRelation ( id,
objectId,
switch,
array $  set 
)

Update a relation using an array of fields to update $set can contains 'params' and 'priority' If $set['params'] is defined then params is also updated in the inverse relation.

Parameters:
int $id the main object id
int $objectId the related object id
string $switch the relation name
array $set array of fields to update
Returns:
boolean

Definition at line 251 of file object_relation.php.

References inverseOf().

ObjectRelation::updateRelationParams ( id,
objectId,
switch,
params = array() 
)

Updates parameters of a relation between objects.

Parameters:
int $id
int $objectId
string $switch
array $params
Returns:
false on failure

Definition at line 229 of file object_relation.php.


The documentation for this class was generated from the following file:
Generated on Fri Dec 11 2015 15:29:47 by Doxygen 1.7.1  BEditaBEdita 3.7 Corylus