TestControllers.php in Drupal 8
File
core/modules/system/tests/modules/menu_test/src/TestControllers.php
View source
<?php
namespace Drupal\menu_test;
use Drupal\Component\Render\FormattableMarkup;
class TestControllers {
public function testLogin() {
return [
'#markup' => 'This is TestControllers::testLogin.',
];
}
public function test1() {
return [
'#markup' => 'test1',
];
}
public function test2() {
return [
'#markup' => 'test2',
];
}
public function testSession() {
if (!isset($_SESSION['menu_test'])) {
$_SESSION['menu_test'] = 0;
}
$_SESSION['menu_test']++;
return [
'#markup' => new FormattableMarkup('Session menu_test is @count', [
'@count' => $_SESSION['menu_test'],
]),
];
}
public function testDerived() {
return [
'#markup' => 'testDerived',
];
}
public function testDefaults($placeholder = NULL) {
if ($placeholder) {
return [
'#markup' => new FormattableMarkup("Sometimes there is a placeholder: '@placeholder'.", [
'@placeholder' => $placeholder,
]),
];
}
else {
return [
'#markup' => 'Sometimes there is no placeholder.',
];
}
}
public function testContextual() {
return [
'#markup' => 'testContextual',
'stuff' => [
'#type' => 'contextual_links',
'#contextual_links' => [
'menu_test_menu' => [
'route_parameters' => [
'bar' => 1,
],
],
],
],
];
}
}