You are here

public function Individual::getPrimaryField in CRM Core 8.3

Same name and namespace in other branches
  1. 8 modules/crm_core_contact/src/Entity/Individual.php \Drupal\crm_core_contact\Entity\Individual::getPrimaryField()
  2. 8.2 modules/crm_core_contact/src/Entity/Individual.php \Drupal\crm_core_contact\Entity\Individual::getPrimaryField()

Gets the primary field.

Parameters

string $field: The primary field name.

Return value

\Drupal\Core\Field\FieldItemListInterface|\Drupal\Core\TypedData\TypedDataInterface The primary field property object.

Throws

\InvalidArgumentException If no primary field is configured. If the configured primary field does not exist.

3 calls to Individual::getPrimaryField()
Individual::getPrimaryAddress in modules/crm_core_contact/src/Entity/Individual.php
Gets the primary address.
Individual::getPrimaryEmail in modules/crm_core_contact/src/Entity/Individual.php
Gets the primary email.
Individual::getPrimaryPhone in modules/crm_core_contact/src/Entity/Individual.php
Gets the primary phone.

File

modules/crm_core_contact/src/Entity/Individual.php, line 165

Class

Individual
CRM Individual Entity Class.

Namespace

Drupal\crm_core_contact\Entity

Code

public function getPrimaryField($field) {
  $type = $this
    ->get('type')->entity;
  $name = empty($type->primary_fields[$field]) ? '' : $type->primary_fields[$field];
  return $this
    ->get($name);
}