Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function postCreate(EntityStorageInterface $storage)
 {
     parent::postCreate($storage);
     // Set the uid field if there is a user with the same email.
     $user_ids = \Drupal::entityQuery('user')->condition('mail', $this->getMail())->execute();
     if (!empty($user_ids)) {
         $this->setUserId(array_pop($user_ids));
     }
     // Copy values for shared fields from existing user.
     if (\Drupal::config('simplenews.settings')->get('subscriber.sync_fields') && ($user = $this->getUser())) {
         foreach ($this->getUserSharedFields($user) as $field_name) {
             $this->set($field_name, $user->get($field_name)->getValue());
         }
     }
 }