You are here

function crm_core_user_sync_user_view in CRM Core 8.3

Same name and namespace in other branches
  1. 8 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 86
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')) {

      /** @var \Drupal\crm_core_user_sync\CrmCoreUserSyncRelation $service */
      $service = \Drupal::service('crm_core_user_sync.relation');
      $individual_id = $service
        ->getIndividualIdFromUserId($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(),
        ];
      }
    }
  }
}