You are here

public function EmailConfirmation::setProperty in Email confirmer 8

Sets a property value.

Parameters

string $key: Property key.

mixed $value: Value to store. NULL will delete the property.

Return value

\Drupal\email_confirmer\EmailConfirmationInterface The called email confirmation entity.

Overrides EmailConfirmationInterface::setProperty

File

src/Entity/EmailConfirmation.php, line 380

Class

EmailConfirmation
Defines the email confirmation entity class.

Namespace

Drupal\email_confirmer\Entity

Code

public function setProperty($key, $value = NULL) {
  $item = $this
    ->get('data')
    ->isEmpty() ? $this
    ->get('data')
    ->appendItem() : $this
    ->get('data')
    ->first();
  $map = $item
    ->getValue();
  if ($value === NULL && isset($map[$key])) {
    unset($map[$key]);
  }
  else {
    $map[$key] = $value;
  }
  $item
    ->setValue($map);
  return $this;
}