You are here

protected function ApigeeEdgeDeveloperIdFieldItem::computeValue in Apigee Edge 8

Computes the values for an item list.

Overrides ComputedItemListTrait::computeValue

File

src/Plugin/Field/FieldType/ApigeeEdgeDeveloperIdFieldItem.php, line 37

Class

ApigeeEdgeDeveloperIdFieldItem
Definition of Apigee Edge Developer ID computed field for User entity.

Namespace

Drupal\apigee_edge\Plugin\Field\FieldType

Code

protected function computeValue() {

  /** @var \Drupal\user\UserInterface $entity */
  $entity = $this
    ->getEntity();

  // Make sure an email address is set.
  // There are cases (registration) where an email might not be set yet.
  if (!$entity
    ->getEmail()) {
    return;
  }
  try {

    /** @var \Drupal\apigee_edge\Entity\Developer $developer */
    $developer = Developer::load($entity
      ->getEmail());
    $value = $developer ? $developer
      ->getDeveloperId() : NULL;
    $this->list[0] = $this
      ->createItem(0, $value);
  } catch (\Exception $exception) {
    watchdog_exception('apigee_edge', $exception);
  }
}