You are here

public function Subscriber::postCreate in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::postCreate()
  2. 8 src/Entity/Subscriber.php \Drupal\simplenews\Entity\Subscriber::postCreate()

Acts on a created entity before hooks are invoked.

Used after the entity is created, but before saving the entity and before any of the presave hooks are invoked.

See the Entity CRUD topic for more information.

Parameters

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

Overrides ContentEntityBase::postCreate

See also

\Drupal\Core\Entity\EntityInterface::create()

File

src/Entity/Subscriber.php, line 299

Class

Subscriber
Defines the simplenews subscriber entity.

Namespace

Drupal\simplenews\Entity

Code

public function postCreate(EntityStorageInterface $storage) {
  parent::postCreate($storage);

  // Fill from a User account with matching uid or email.
  if ($user = $this
    ->getUser()) {
    $this
      ->fillFromAccount($user);
  }
}