TestPageTestController.php in Drupal 9
File
core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php
View source
<?php
namespace Drupal\test_page_test\Controller;
use Drupal\user\Entity\Role;
class TestPageTestController {
public function testPage() {
$link_text = t('Visually identical test links');
return [
'#title' => t('Test page'),
'#markup' => t('Test page text.') . "<a href=\"/user/login\">{$link_text}</a><a href=\"/user/register\">{$link_text}</a>",
'#attached' => [
'drupalSettings' => [
'test-setting' => 'azAZ09();.,\\\\/-_{}',
],
],
];
}
public function testPageVarDump() {
$role = Role::create([
'id' => 'test_role',
]);
dump($role);
return [
'#title' => t('Test page with var dump'),
'#markup' => t('Test page text.'),
];
}
}