You are here

function crm_core_user_sync_user_view in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_user_sync/crm_core_user_sync.module \crm_core_user_sync_user_view()
  2. 8.2 modules/crm_core_user_sync/crm_core_user_sync.module \crm_core_user_sync_user_view()
  3. 7 modules/crm_core_user_sync/crm_core_user_sync.module \crm_core_user_sync_user_view()

Implements hook_user_view().

File

modules/crm_core_user_sync/crm_core_user_sync.module, line 80
CRM Core User Synchronization module.

Code

function crm_core_user_sync_user_view(array &$build, UserInterface $account, EntityViewDisplayInterface $display) {
  $contact_show = \Drupal::config('crm_core_user_sync.settings')
    ->get('contact_show');
  if ($contact_show) {
    if ($display
      ->getComponent('contact_information')) {
      $individual_id = \Drupal::service('crm_core_user_sync.relation')
        ->getUserIndividualId($account
        ->id());
      if ($individual_id) {
        $individual = Individual::load($individual_id);
        $build['contact_information'] = [
          '#type' => 'item',
          '#title' => t('Contact Information'),
          '#markup' => '<h4 class="label">' . t('Contact name') . '</h4> ' . $individual
            ->label(),
        ];
      }
    }
  }
}