You are here

trait LoginDestinationCreationTrait in Login Destination 8

Same name and namespace in other branches
  1. 8.2 tests/src/Traits/LoginDestinationCreationTrait.php \Drupal\Tests\login_destination\Traits\LoginDestinationCreationTrait

Provides methods to create login destination rules.

This trait is meant to be used only by test classes.

Hierarchy

1 file declares its use of LoginDestinationCreationTrait
RedirectTest.php in tests/src/Functional/RedirectTest.php

File

tests/src/Traits/LoginDestinationCreationTrait.php, line 13

Namespace

Drupal\Tests\login_destination\Traits
View source
trait LoginDestinationCreationTrait {

  /**
   * Creates a login destination rule based on default settings.
   *
   * @param array $settings
   *   (optional) An associative array of settings for the rule, as used in
   *   entity_create(). Override the defaults by specifying the key and value
   *   in the array.
   *
   * @return \Drupal\login_destination\Entity\LoginDestination
   *   The created login destination rule.
   */
  protected function createLoginDestinationRule(array $settings = []) {
    $settings += [
      'name' => Unicode::strtolower($this
        ->randomMachineName()),
      'label' => $this
        ->randomMachineName(),
    ];
    $rule = LoginDestination::create($settings);
    $rule
      ->save();
    return $rule;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LoginDestinationCreationTrait::createLoginDestinationRule protected function Creates a login destination rule based on default settings.