You are here

function crm_core_contact_common_template_preprocess in CRM Core 8.3

Common theme template additions.

Parameters

string $entity_id: Entity.

array $variables: Variables.

2 calls to crm_core_contact_common_template_preprocess()
template_preprocess_crm_core_individual in modules/crm_core_contact/crm_core_contact.module
Process variables for CRM Core Individual.
template_preprocess_crm_core_organization in modules/crm_core_contact/crm_core_contact.module
Process variables for CRM Core Organization.

File

modules/crm_core_contact/crm_core_contact.module, line 60
Provides default CRM Core Contact entities and the ability to create more.

Code

function crm_core_contact_common_template_preprocess(string $entity_id, array &$variables) {
  $variables['view_mode'] = $variables['elements']['#view_mode'];

  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  $entity = $variables['elements']['#' . $entity_id];
  $variables['crm_core_contact'] = $entity;
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }

  // Add classes based on the type of contact.
  $variables['attributes']['class'][] = $entity_id;
  $variables['attributes']['class'][] = $entity_id . '-' . $entity
    ->bundle();
}