You are here

public function Developer::__construct in Apigee Edge 8

Developer constructor.

Parameters

array $values: An array of values to set, keyed by property name.

null|string $entity_type: Type of the entity. It is optional because constructor sets its default value.

\Apigee\Edge\Entity\EntityInterface|null $decorated: The SDK entity that this Drupal entity decorates.

Overrides EdgeEntityBase::__construct

File

src/Entity/Developer.php, line 121

Class

Developer
Defines the Developer entity class.

Namespace

Drupal\apigee_edge\Entity

Code

public function __construct(array $values, ?string $entity_type = NULL, EdgeEntityInterface $decorated = NULL) {
  $entity_type = $entity_type ?? 'developer';

  // Callers expect that the status is always either 'active' or 'inactive',
  // never null.
  if (!isset($values['status'])) {
    $values['status'] = static::STATUS_ACTIVE;
  }
  parent::__construct($values, $entity_type, $decorated);

  // Property must be initialized here because it is used as entity's
  // primary id in Drupal.
  // @see static::idProperties()
  // @see static::drupalEntityId()
  $this->originalEmail = $this->originalEmail ?? $this->decorated
    ->getEmail();
  $this->companiesCache = \Drupal::service('apigee_edge.controller.cache.developer_companies');

  // If we got a non-empty companies list from the API response then
  // cache it otherwise ignore it. See more details in getCompanies().
  if ($this->decorated
    ->getCompanies()) {
    $this->companiesCache
      ->saveCompanies([
      $this->decorated,
    ]);
  }
}