Skip to content

Commit a5945a9

Browse files
committedSep 23, 2014
move router transformer into service.
1 parent 851f557 commit a5945a9

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed
 

‎kernel.module

+1-17
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,7 @@ function kernel_init() {
9999
try {
100100
$path = current_path();
101101
$router->match(base_path() . $path);
102-
$router_item = array(
103-
'path' => $path,
104-
'page_callback' => 'kernel_callback',
105-
'page_arguments' => array(\Symfony\Component\HttpFoundation\Request::createFromGlobals()),
106-
'delivery_callback' => '',
107-
'tab_parent' => '',
108-
'tab_root' => $path,
109-
'title' => '',
110-
'type' => MENU_CALLBACK,
111-
'include_file' => drupal_get_path('module', 'kernel') . '/kernel.pages.inc',
112-
'href' => $path,
113-
'tab_root_href' => $path,
114-
'tab_parent_href' => '',
115-
'access' => TRUE,
116-
'original_map' => arg(NULL, $path),
117-
'map' => arg(NULL, $path),
118-
);
102+
$router_item = $c['router.transformer']($path);
119103

120104
// If the desire is to output a whole Symfony response, use:
121105
//

‎src/DrupalKernelServiceProvider.php

+25
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,30 @@ public function register(\Pimple\Container $pimple)
6464
$pimple['router'] = function ($c) {
6565
return $c['container']->get('router');
6666
};
67+
$pimple['router.transformer'] = $pimple->protect(
68+
/**
69+
* @param $path
70+
*
71+
* @return array
72+
*/
73+
function ($path) {
74+
return array(
75+
'path' => $path,
76+
'page_callback' => 'kernel_callback',
77+
'page_arguments' => array(\Symfony\Component\HttpFoundation\Request::createFromGlobals()),
78+
'delivery_callback' => '',
79+
'tab_parent' => '',
80+
'tab_root' => $path,
81+
'title' => '',
82+
'type' => MENU_CALLBACK,
83+
'include_file' => drupal_get_path('module', 'kernel') . '/kernel.pages.inc',
84+
'href' => $path,
85+
'tab_root_href' => $path,
86+
'tab_parent_href' => '',
87+
'access' => TRUE,
88+
'original_map' => arg(NULL, $path),
89+
'map' => arg(NULL, $path),
90+
);
91+
});
6792
}
6893
}

0 commit comments

Comments
 (0)