getEntityDuplicate example

->activate()
      ->save();

    return $user;
  }

  /** * {@inheritdoc} */
  protected function createAnotherEntity($key) {
    /** @var \Drupal\user\UserInterface $user */
    $user = $this->getEntityDuplicate($this->entity, $key);
    $user->setUsername($user->label() . '_' . $key);
    $user->setEmail("$key@example.com");
    $user->save();
    return $user;
  }

  /** * {@inheritdoc} */
  public function testDeleteIndividual() {
    $this->config('user.settings')->set('cancel_method', 'user_cancel_delete')->save(TRUE);

    

  protected function createAnotherEntity($key) {
    $duplicate = $this->getEntityDuplicate($this->entity, $key);
    // Some entity types are not stored, hence they cannot be reloaded.     if (get_class($this->entityStorage) !== ContentEntityNullStorage::class) {
      $duplicate->set('field_rest_test', 'Second collection entity');
    }
    $duplicate->save();
    return $duplicate;
  }

  /** * {@inheritdoc} */
  
Home | Imprint | This part of the site doesn't use cookies.