Skip to content
This repository was archived by the owner on Feb 17, 2022. It is now read-only.

7.x 2.x easy routing

Andy Truong edited this page Jan 16, 2014 · 11 revisions

Easy Routing — [7.x-2.x]

Faster way to define menu item in Drupal 7:

# %atest_route/config/route.yml
routes:
  atest_route/drupal:
    title: Hello Drupal
    page callback: atest_route_page_callback
    page arguments: ['Andy Truong']
    access arguments: ['access content']
  atest_route/controller:
    title: Hello
    access arguments: ['access content']
    controller: [\Drupal\atest_route\Controller\HelloController, helloAction, {name: 'Andy Truong'}]
  atest_route/string_template:
    title: String Template
    access arguments: ['access content']
    template_string: 'Hello {{ name }}'
    variables: {name: Andy Truong}
  'atest_route/cache/%user':
    title: Route supports caching
    access arguments: ['access content']
    template_string: >
      <strong>Username:</strong> {{ user.name }}.
      <strong>Time:</strong> {{ "now"|date("m/d/Y h:m:s") }}
    cache:
      # DRUPAL_CACHE_CUSTOM, DRUPAL_CACHE_GLOBAL, DRUPAL_CACHE_PER_PAGE,
      # DRUPAL_CACHE_PER_ROLE, DRUPAL_CACHE_PER_USER, DRUPAL_NO_CACHE
      type: constant('DRUPAL_CACHE_GLOBAL')
      bin: cache
      ttl: + 15 minutes
      tags: ['at_test']

Supported routes:

Other

Clone this wiki locally