function crm_core_relationship_is_relationship_type in CRM Core 8.2
Same name and namespace in other branches
- 8.3 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_is_relationship_type()
- 8 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_is_relationship_type()
- 7 modules/crm_core_relationship/crm_core_relationship.module \crm_core_relationship_is_relationship_type()
Check if relation_type is CRM relationship_type.
Parameters
$relation_type: Relation type name or relation object provided by Relation module.
9 calls to crm_core_relationship_is_relationship_type()
- crm_core_relationship_entity_info_alter in modules/
crm_core_relationship_ui/ crm_core_relationship_ui.module - Implements hook_entity_info_alter().
- crm_core_relationship_field_attach_create_bundle in modules/
crm_core_relationship/ crm_core_relationship.module - Implements hook_field_attach_create_bundle.
- crm_core_relationship_get_relationships in modules/
crm_core_relationship/ crm_core_relationship.module - Return a list of relation bundle that are crm_core_relationship
- crm_core_relationship_load_contact_types in modules/
crm_core_relationship/ crm_core_relationship.module - Return contact types available for specific relationship type.
- crm_core_relationship_load_relationship_types in modules/
crm_core_relationship/ crm_core_relationship.module - Return relationship types that can be applied to specific contact type.
File
- modules/
crm_core_relationship/ crm_core_relationship.module, line 191 - CRM Core Relationship, handles relationship logic and API.
Code
function crm_core_relationship_is_relationship_type($relation_type) {
static $types = array();
if (is_object($relation_type)) {
$relation_type_object = $relation_type;
$relation_type = $relation_type_object->relation_type;
}
if (isset($types[$relation_type])) {
return $types[$relation_type];
}
if (!isset($relation_type_object)) {
$relation_type_object = RelationType::load($relation_type);
}
if ($relation_type_object) {
$ret = TRUE;
// It should be between CRM contact types only
$ret = $ret && crm_core_relationship_is_contact_bundles($relation_type_object->source_bundles);
if ($relation_type_object->directional) {
$ret = $ret && crm_core_relationship_is_contact_bundles($relation_type_object->target_bundles);
}
// Arity should be equal to 2
$ret = $ret && $relation_type_object->min_arity == 2 && $relation_type_object->max_arity == 2;
$types[$relation_type] = $ret;
return $ret;
}
return FALSE;
}