You are here

public function CrmCoreUserSyncRelationRules::getContactType in CRM Core 8.3

Same name and namespace in other branches
  1. 8 modules/crm_core_user_sync/src/CrmCoreUserSyncRelationRules.php \Drupal\crm_core_user_sync\CrmCoreUserSyncRelationRules::getContactType()

Get contact type resolved from configured synchronization rules.

Parameters

\Drupal\user\UserInterface $account: User account to check.

Return value

string|false Intividual contact type (bundle) to be user for this user account.

1 call to CrmCoreUserSyncRelationRules::getContactType()
CrmCoreUserSyncRelationRules::valid in modules/crm_core_user_sync/src/CrmCoreUserSyncRelationRules.php
Checks if provided contact can be linked to this account.

File

modules/crm_core_user_sync/src/CrmCoreUserSyncRelationRules.php, line 102

Class

CrmCoreUserSyncRelationRules
CrmCoreUserSyncRelation service.

Namespace

Drupal\crm_core_user_sync

Code

public function getContactType(UserInterface $account) {
  foreach ($this
    ->getRules() as $rule) {
    if ($rule['enabled'] && $account
      ->hasRole($rule['role'])) {
      return $rule['contact_type'];
    }
  }
  return FALSE;
}