function AccessPolicyProcessorInFibersTest::lazyBuilderCheckAccessCallback

Same name and namespace in other branches
  1. main core/tests/Drupal/KernelTests/Core/Session/AccessPolicyProcessorInFibersTest.php \Drupal\KernelTests\Core\Session\AccessPolicyProcessorInFibersTest::lazyBuilderCheckAccessCallback()

Lazy builder that checks permissions on a different user.

Attributes

#[TrustedCallback]

File

core/tests/Drupal/KernelTests/Core/Session/AccessPolicyProcessorInFibersTest.php, line 94

Class

AccessPolicyProcessorInFibersTest
Tests the behavior of the access policy processor running inside fibers.

Namespace

Drupal\KernelTests\Core\Session

Code

public static function lazyBuilderCheckAccessCallback() : array {
  $user3 = new UserSession([
    'uid' => 3,
    'roles' => [
      'test_role' => 'test_role',
    ],
  ]);
  return [
    '#markup' => new FormattableMarkup('User @id can administer modules.', [
      '@id' => $user3->id(),
    ]),
    '#access' => $user3->hasPermission('administer modules'),
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.