class CommonTestController

Controller routines for common_test routes.

Hierarchy

Expanded class hierarchy of CommonTestController

File

drupal/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php, line 16
Contains \Drupal\common_test\Controller\CommonTestController.

Namespace

Drupal\common_test\Controller
View source
class CommonTestController implements ControllerInterface {

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static();
  }

  /**
   * Returns links to the current page, with and without query strings.
   *
   * Using #type causes these links to be rendered with l().
   */
  public function lActiveClass() {
    return array(
      'no_query' => array(
        '#type' => 'link',
        '#title' => t('Link with no query string'),
        '#href' => current_path(),
      ),
      'with_query' => array(
        '#type' => 'link',
        '#title' => t('Link with a query string'),
        '#href' => current_path(),
        '#options' => array(
          'query' => array(
            'foo' => 'bar',
            'one' => 'two',
          ),
        ),
      ),
      'with_query_reversed' => array(
        '#type' => 'link',
        '#title' => t('Link with the same query string in reverse order'),
        '#href' => current_path(),
        '#options' => array(
          'query' => array(
            'one' => 'two',
            'foo' => 'bar',
          ),
        ),
      ),
    );
  }

  /**
   * Returns links to the current page, with and without query strings.
   *
   * Using #theme causes these links to be rendered with theme_link().
   */
  public function themeLinkActiveClass() {
    return array(
      'no_query' => array(
        '#theme' => 'link',
        '#text' => t('Link with no query string'),
        '#path' => current_path(),
      ),
      'with_query' => array(
        '#theme' => 'link',
        '#text' => t('Link with a query string'),
        '#path' => current_path(),
        '#options' => array(
          'query' => array(
            'foo' => 'bar',
            'one' => 'two',
          ),
        ),
      ),
      'with_query_reversed' => array(
        '#theme' => 'link',
        '#text' => t('Link with the same query string in reverse order'),
        '#path' => current_path(),
        '#options' => array(
          'query' => array(
            'one' => 'two',
            'foo' => 'bar',
          ),
        ),
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommonTestController::create public static function Instantiates a new instance of this controller. Overrides ControllerInterface::create
CommonTestController::lActiveClass public function Returns links to the current page, with and without query strings.
CommonTestController::themeLinkActiveClass public function Returns links to the current page, with and without query strings.