You are here

public function Organization::getPrimaryField in CRM Core 8.3

Same name and namespace in other branches
  1. 8 modules/crm_core_contact/src/Entity/Organization.php \Drupal\crm_core_contact\Entity\Organization::getPrimaryField()
  2. 8.2 modules/crm_core_contact/src/Entity/Organization.php \Drupal\crm_core_contact\Entity\Organization::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 Organization::getPrimaryField()
Organization::getPrimaryAddress in modules/crm_core_contact/src/Entity/Organization.php
Gets the primary address.
Organization::getPrimaryEmail in modules/crm_core_contact/src/Entity/Organization.php
Gets the primary email.
Organization::getPrimaryPhone in modules/crm_core_contact/src/Entity/Organization.php
Gets the primary phone.

File

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

Class

Organization
CRM Organization Entity Class.

Namespace

Drupal\crm_core_contact\Entity

Code

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