forked from paul-m/composer-drupal-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage_example.routing.yml
52 lines (46 loc) · 2.49 KB
/
page_example.routing.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# In order to to create pages it is necessary to define routes for them. A route
# maps a URL path to a controller. It defines with what function or method will
# be called when a URL is accessed. The following lines defines three of them
# for this module.
# Menu items corresponding to these URLs are defined separately in the
# page_example.menu_links.yml file.
# If the user accesses http://example.com/?q=examples/page_example, the routing
# system will look for a route with that path. In this case it will find a
# match, and execute the _content callback. In this case the callback is defined
# as a classname ("\Drupal\page_example\Controller\PageExampleController")
# and a method ("description").
# Access to this path is not restricted. This is notated as _access: 'TRUE'.
page_example_description:
path: 'examples/page_example'
defaults:
_content: '\Drupal\page_example\Controller\PageExampleController::description'
requirements:
_access: 'TRUE'
# If the user accesses http://example.com/?q=examples/page_example/simple,
# the routing system will look for a route with that path. In this case it will
# find a match, and execute the _content callback. Access to this path requires
# "access simple page" permission.
page_example_simple:
path: 'examples/page_example/simple'
defaults:
_content: '\Drupal\page_example\Controller\PageExampleController::simple'
requirements:
_permission: 'access simple page'
# If the user accesses
# http://example.com/?q=examples/page_example/arguments/1/2, the routing system
# will first look for examples/page_example/arguments/1/2. Not finding a match,
# it will look for examples/page_example/arguments/1/{*}. Again not finding a
# match, it will look for examples/page_example/arguments/{*}/2. Yet again not
# finding a match, it will look for examples/page_example/arguments/{*}/{*}.
# This time it finds a match, and so it will execute the _content callback. In
# this case, it's PageExampleController::arguments().
# Since the parameters are passed to the function after the match, the function
# can do additional checking or make use of them before executing the callback
# function. The placeholder names "first" and "second" are arbitrary but must
# match the variable names in the callback method, e.g. "$first" and "$second".
page_example_arguments:
path: 'examples/page_example/arguments/{first}/{second}'
defaults:
_content: '\Drupal\page_example\Controller\PageExampleController::arguments'
requirements:
_permission: 'access arguments page'