You are here

protected function LoginDestinationCreationTrait::createLoginDestinationRule in Login Destination 8.2

Same name and namespace in other branches
  1. 8 tests/src/Traits/LoginDestinationCreationTrait.php \Drupal\Tests\login_destination\Traits\LoginDestinationCreationTrait::createLoginDestinationRule()

Creates a login destination rule based on default settings.

Parameters

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 value

\Drupal\login_destination\Entity\LoginDestination The created login destination rule.

1 call to LoginDestinationCreationTrait::createLoginDestinationRule()
RedirectTest::createLoginDestinationToNode1 in tests/src/Functional/RedirectTest.php
Creates a login destination to /node/1.

File

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

Class

LoginDestinationCreationTrait
Provides methods to create login destination rules.

Namespace

Drupal\Tests\login_destination\Traits

Code

protected function createLoginDestinationRule(array $settings = []) {
  $settings += [
    'name' => mb_strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomMachineName(),
  ];
  $rule = LoginDestination::create($settings);
  $rule
    ->save();
  return $rule;
}