You are here

function civicrm_entity_theme in CiviCRM Entity 7.2

Same name and namespace in other branches
  1. 8.3 civicrm_entity.module \civicrm_entity_theme()

Implements hook_theme().

Lets Drupal know to look for templates for the entity types

Return value

array $themes

File

./civicrm_entity.module, line 144

Code

function civicrm_entity_theme() {
  $civicrm_entity_info = civicrm_entity_get_supported_entity_info();
  $enabled_entities = _civicrm_entity_enabled_entities();
  $themes = array();
  foreach ($civicrm_entity_info as $drupal_entity => $data) {
    if (!empty($enabled_entities[$drupal_entity])) {
      $dashkey = str_replace('_', '-', $drupal_entity);
      if (isset($data['theme'])) {
        $themes[$drupal_entity] = [
          'render element' => 'elements',
        ];
        if (isset($data['theme']['template'])) {
          $themes[$drupal_entity]['template'] = $data['theme']['template'];
        }
        if (isset($data['theme']['path'])) {
          $themes[$drupal_entity]['path'] = $data['theme']['path'];
        }
      }
    }
  }
  return $themes;
}