You are here

class TestControllers in Zircon Profile 8.0

Same name in this branch
  1. 8.0 core/modules/system/tests/modules/router_test_directory/src/TestControllers.php \Drupal\router_test\TestControllers
  2. 8.0 core/modules/system/tests/modules/paramconverter_test/src/TestControllers.php \Drupal\paramconverter_test\TestControllers
  3. 8.0 core/modules/system/tests/modules/menu_test/src/TestControllers.php \Drupal\menu_test\TestControllers
Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/menu_test/src/TestControllers.php \Drupal\menu_test\TestControllers

Controllers for testing the menu integration routing system.

Hierarchy

Expanded class hierarchy of TestControllers

File

core/modules/system/tests/modules/menu_test/src/TestControllers.php, line 15
Contains \Drupal\menu_test\TestControllers.

Namespace

Drupal\menu_test
View source
class TestControllers {

  /**
   * Returns page to be used as a login path.
   */
  public function testLogin() {
    return [
      '#markup' => 'This is TestControllers::testLogin.',
    ];
  }

  /**
   * Prints out test data.
   */
  public function test1() {
    return [
      '#markup' => 'test1',
    ];
  }

  /**
   * Prints out test data.
   */
  public function test2() {
    return [
      '#markup' => 'test2',
    ];
  }

  /**
   * Prints out test data.
   */
  public function testSession() {
    if (!isset($_SESSION['menu_test'])) {
      $_SESSION['menu_test'] = 0;
    }
    $_SESSION['menu_test']++;
    return [
      '#markup' => SafeMarkup::format('Session menu_test is @count', [
        '@count' => $_SESSION['menu_test'],
      ]),
    ];
  }

  /**
   * Prints out test data.
   */
  public function testDerived() {
    return [
      '#markup' => 'testDerived',
    ];
  }

  /**
   * Prints out test data.
   *
   * @param string|null $placeholder
   *   A placeholder for the return string.
   *
   * @return string
   *   The string for this route.
   */
  public function testDefaults($placeholder = NULL) {
    if ($placeholder) {
      return [
        '#markup' => SafeMarkup::format("Sometimes there is a placeholder: '@placeholder'.", array(
          '@placeholder' => $placeholder,
        )),
      ];
    }
    else {
      return [
        '#markup' => 'Sometimes there is no placeholder.',
      ];
    }
  }

  /**
   * Prints out test data with contextual links.
   */
  public function testContextual() {
    return [
      '#markup' => 'testContextual',
      'stuff' => [
        '#type' => 'contextual_links',
        '#contextual_links' => [
          'menu_test_menu' => [
            'route_parameters' => [
              'bar' => 1,
            ],
          ],
        ],
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TestControllers::test1 public function Prints out test data.
TestControllers::test2 public function Prints out test data.
TestControllers::testContextual public function Prints out test data with contextual links.
TestControllers::testDefaults public function Prints out test data.
TestControllers::testDerived public function Prints out test data.
TestControllers::testLogin public function Returns page to be used as a login path.
TestControllers::testSession public function Prints out test data.