You are here

public static function SocialApi::preCreate in Social API 8.2

Changes the values of an entity before it is created.

Load defaults for example.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

mixed[] $values: An array of values to set, keyed by property name. If the entity type has bundles the bundle key has to be specified.

Overrides EntityBase::preCreate

File

src/Entity/SocialApi.php, line 30

Class

SocialApi
Defines a base class for Social API content entities.

Namespace

Drupal\social_api\Entity

Code

public static function preCreate(EntityStorageInterface $storage, array &$values) {
  if (isset($values['token'])) {
    $values['token'] = static::encryptToken($values['token']);
  }
  return parent::preCreate($storage, $values);
}