You are here

function civicrm_entity_entity_property_info_alter in CiviCRM Entity 7

Same name and namespace in other branches
  1. 7.2 civicrm_entity.module \civicrm_entity_entity_property_info_alter()

Here we declare Selected CiviCRM entities fields to Drupal.

Some trickiness here as declaring the 'schema' via our special civi schema function seems to cause fields to be declared twice if we us property_info rather than property_info_alter.

At the moment civicrm_relationship_type is the only entity being managed through 'our' schema.

Parameters

$info:

File

./civicrm_entity.module, line 251
Implement CiviCRM entities as a Drupal Entity.

Code

function civicrm_entity_entity_property_info_alter(&$info) {
  if (!civicrm_initialize(TRUE)) {
    return;
  }

  // We'll start with a few basic entities but we could get them the
  // same way the API explorer does.
  $entities = _civicrm_entity_enabled_entities();
  foreach ($entities as $drupal_entity => $civicrm_entity) {
    $info[$drupal_entity]['properties'] = _civicrm_entity_getproperties($civicrm_entity, 'property_info');

    // $info[$drupal_entity]['bundles'] = array();
  }

  // This makes the drupal user available when chaining from a rule.
  $info['civicrm_contact']['properties']['civicrm_user'] = array(
    'label' => 'Drupal User',
    'description' => 'Drupal User for contact',
    'type' => 'user',
  );

  // Attach a CiviCRM Contact property to drupal users.
  $info['user']['properties']['civicrm_contact'] = array(
    'label' => 'CiviCRM Contact',
    'description' => 'CiviCRM Contact for user',
    'type' => 'civicrm_contact',
    'field' => FALSE,
    'translatable' => FALSE,
    'getter callback' => 'civicrm_entity_user_contact_get',
  );
  return $info;
}