You are here

function relation_get_types in Relation 7

Loads a relation type (bundle), or all relation bundles.

Parameters

$types: An array of machine names of the relation types to be loaded. If $types is empty, load all relation types.

Return value

A an array of relation type records in the same format as expected by relation_type_save(), keyed by relation_type.

21 calls to relation_get_types()
RelationCtoolsTestCase::testRelationLoadDefaultRelationTypes in tests/relation.ctools.test
RelationFeedsProcessor::getTypeInfo in relation_feeds/RelationFeedsProcessor.inc
Get configured relation type
relation_dummy_field_field_instance_settings_form in relation_dummy_field/relation_dummy_field.module
Implements hook_field_instance_settings_form().
relation_entity_collector in relation_entity_collector/relation_entity_collector.module
The entity_collector form.
relation_entity_delete in ./relation.module
Implements hook_entity_delete().

... See full list

File

./relation.module, line 337
Describes relations between entities.

Code

function relation_get_types($types = array()) {
  if (module_exists('ctools')) {
    ctools_include('export');
  }
  if (function_exists('ctools_export_crud_load_multiple')) {
    $relation_types = $types ? ctools_export_crud_load_multiple('relation_type', $types) : ctools_export_crud_load_all('relation_type');
    static $recurse = FALSE;
    if (!$recurse) {
      $recurse = TRUE;
      foreach ($relation_types as $type => $data) {
        if (!empty($data->in_code_only)) {
          relation_type_ensure_instance($type);
        }
      }
    }
    $recurse = FALSE;
  }
  else {
    $query = db_select('relation_type', 'rt')
      ->fields('rt', array(
      'relation_type',
      'label',
      'reverse_label',
      'directional',
      'transitive',
      'r_unique',
      'min_arity',
      'max_arity',
    ));
    if ($types) {
      $query
        ->condition('relation_type', $types);
    }
    $results = $query
      ->execute();
    $relation_types = array();
    foreach ($results as $relation_type) {
      $relation_types[$relation_type->relation_type] = $relation_type;
    }
    _relation_get_types_bundles($relation_types);
  }
  return $relation_types;
}