You are here

function civicrm_entity_entity_info in CiviCRM Entity 7

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

Here we declare selected CiviCRM entities to Drupal.

This is necessary for entity module to pick them up.

File

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

Code

function civicrm_entity_entity_info() {
  $entities = _civicrm_entity_enabled_entities();
  foreach ($entities as $drupal_entity => $civicrm_entity) {
    $info[$drupal_entity] = array(
      'description' => $civicrm_entity,
      'optional' => TRUE,
      'label' => "CiviCRM " . ucwords($civicrm_entity),
      'module' => 'civicrm_entity',
      'controller class' => 'CivicrmEntityController',
      'metadata controller class' => 'CivicrmEntityMetadataController',
      'views controller class' => 'CiviCRMEntityDefaultViewsController',
      'ui class' => 'RulesDataUIEntity',
      'fieldable' => TRUE,
      'extra fields controller class' => 'EntityDefaultExtraFieldsController',
      'access callback' => 'civicrm_entity_access',
      'admin ui' => array(
        'path' => $drupal_entity,
        'controller class' => 'CivicrmEntityUIController',
        'file' => 'civicrm_entity_controller.inc',
      ),
      'bundles' => array(
        $drupal_entity => array(
          'label' => t('CiviCRM @entity', array(
            '@entity' => ucwords($civicrm_entity),
          )),
          'admin' => array(
            'path' => 'admin/structure/types/manage/' . $drupal_entity,
            'access arguments' => array(
              'administer CiviCRM',
            ),
          ),
        ),
      ),
      'view modes' => array(
        'full' => array(
          'label' => t('Default'),
          'custom settings' => TRUE,
        ),
      ),
      'entity keys' => array(
        'id' => 'id',
        'label' => _civicrm_entity_labels($drupal_entity),
      ),
      'base table' => $drupal_entity,
    );
    $label_callback = 'civicrm_entity_' . $drupal_entity . '_label_callback';
    if (function_exists($label_callback)) {
      $info[$drupal_entity]['label callback'] = $label_callback;
    }
  }

  // OK - so we are not doing this for the ones declared in views
  // until more testing has been done.
  $info['civicrm_relationship_type']['views controller class'] = 'CiviCRMEntityDefaultViewsController';
  return $info;
}