TestControllers.php

Same filename in this branch
  1. main core/modules/system/tests/modules/menu_test/src/TestControllers.php
  2. main core/modules/system/tests/modules/router_test_directory/src/TestControllers.php
Same filename and directory in other branches
  1. 11.x core/modules/system/tests/modules/paramconverter_test/src/TestControllers.php
  2. 11.x core/modules/system/tests/modules/menu_test/src/TestControllers.php
  3. 11.x core/modules/system/tests/modules/router_test_directory/src/TestControllers.php
  4. 10 core/modules/system/tests/modules/paramconverter_test/src/TestControllers.php
  5. 10 core/modules/system/tests/modules/menu_test/src/TestControllers.php
  6. 10 core/modules/system/tests/modules/router_test_directory/src/TestControllers.php
  7. 9 core/modules/system/tests/modules/paramconverter_test/src/TestControllers.php
  8. 9 core/modules/system/tests/modules/menu_test/src/TestControllers.php
  9. 9 core/modules/system/tests/modules/router_test_directory/src/TestControllers.php
  10. 8.9.x core/modules/system/tests/modules/paramconverter_test/src/TestControllers.php
  11. 8.9.x core/modules/system/tests/modules/menu_test/src/TestControllers.php
  12. 8.9.x core/modules/system/tests/modules/router_test_directory/src/TestControllers.php

Namespace

Drupal\paramconverter_test

File

core/modules/system/tests/modules/paramconverter_test/src/TestControllers.php

View source
<?php

declare (strict_types=1);
namespace Drupal\paramconverter_test;

use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface;

/**
 * Controller routine for testing the paramconverter.
 */
class TestControllers {
  public function testUserNodeFoo(EntityInterface $user, NodeInterface $node, $foo) {
    $foo = is_object($foo) ? $foo->label() : $foo;
    return [
      '#markup' => "user: {$user->label()}, node: {$node->label()}, foo: {$foo}",
    ];
  }
  public function testNodeSetParent(NodeInterface $node, NodeInterface $parent) {
    return [
      '#markup' => "Setting '{$parent->label()}' as parent of '{$node->label()}'.",
    ];
  }
  public function testEntityLanguage(NodeInterface $node) {
    $build = [
      '#markup' => $node->label(),
    ];
    \Drupal::service('renderer')->addCacheableDependency($build, $node);
    return $build;
  }

}

Classes

Title Deprecated Summary
TestControllers Controller routine for testing the paramconverter.

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