public function BigPipeSessionlessTestController::test in Sessionless BigPipe 8
Same name and namespace in other branches
- 2.x tests/modules/big_pipe_sessionless_test/src/BigPipeSessionlessTestController.php \Drupal\big_pipe_sessionless_test\BigPipeSessionlessTestController::test()
Returns a all BigPipe placeholder test case render arrays.
Return value
array
Overrides BigPipeTestController::test
1 string reference to 'BigPipeSessionlessTestController::test'
- big_pipe_sessionless_test.routing.yml in tests/
modules/ big_pipe_sessionless_test/ big_pipe_sessionless_test.routing.yml - tests/modules/big_pipe_sessionless_test/big_pipe_sessionless_test.routing.yml
File
- tests/
modules/ big_pipe_sessionless_test/ src/ BigPipeSessionlessTestController.php, line 13
Class
Namespace
Drupal\big_pipe_sessionless_testCode
public function test() {
$build = parent::test();
$has_session = \Drupal::service('session_configuration')
->hasSession(\Drupal::requestStack()
->getMasterRequest());
// We can't test CSRF tokens for no-session requests.
if (!$has_session) {
unset($build['html_attribute_value_subset']);
}
// Edge case for no-session (and hence anonymous) responses: active links.
// @see \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter
$build['active_link'] = [
'#type' => 'link',
'#title' => 'This should be marked active',
'#url' => Url::fromRoute('big_pipe_sessionless_test'),
'#options' => [
'set_active_class' => TRUE,
],
];
$build['inactive_link'] = [
'#type' => 'link',
'#title' => 'This should be marked inactive',
'#url' => Url::fromRoute('<front>'),
'#options' => [
'set_active_class' => TRUE,
],
];
return $build;
}