function relation_type_create in Relation 7
Creates a relation bundle.
Parameters
$info: Array of relation type settings. All but relation_type are optional, although if the bundles arrays are empty, relations might be difficult to create! Keys are:
- relation_type: Relation type machine name (string).
- label: Relation type human-readable name (string). Defaults to duplicating relation_type.
- directional: whether relation is directional (boolean). Defaults to FALSE.
- transitive: whether relation is transitive (boolean). Defaults to FALSE.
- r_unique: whether relations of this type are unique (boolean). Defaults to FALSE.
- min_arity: minimum number of entities in relations of this type (int >= 2). Defaults to 2.
- max_arity: maximum number of entities in relations of this type (int >= min_arity). Defaults to 2.
- source_bundles: array containing allowed bundle keys. This is used for both directional and non-directional relations. Bundle key arrays are of the form 'entity:bundle', eg. 'node:article', or 'entity:*' for all bundles of the type.
- target_bundles: array containing arrays allowed target bundle keys. This is the same format as source_bundles, but is only used for directional relations.
Return value
Relation type object, or FALSE if creation fails.
1 call to relation_type_create()
- relation_type_save in ./
relation.module - Saves a relation bundle.
File
- ./
relation.module, line 218 - Describes relations between entities.
Code
function relation_type_create($info = array()) {
$info = (array) $info;
if (empty($info['relation_type'])) {
return FALSE;
}
$info += array(
'min_arity' => 2,
'max_arity' => 2,
'directional' => FALSE,
'transitive' => FALSE,
'r_unique' => FALSE,
'source_bundles' => array(),
'target_bundles' => array(),
);
if (empty($info['label'])) {
$info['label'] = $info['relation_type'];
}
if (empty($info['reverse_label'])) {
// Directional relations should have a reverse label, but if they don't,
// or if they are symmetric:
$info['reverse_label'] = $info['label'];
}
return (object) $info;
}