Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
restws
Commits
a588261a
Commit
a588261a
authored
Jul 13, 2016
by
fago
Browse files
Improve default menu items generated for entity types that do not have any.
parent
b16e8a22
Changes
2
Hide whitespace changes
Inline
Side-by-side
restws.install
View file @
a588261a
...
...
@@ -12,3 +12,10 @@
function
restws_update_7001
()
{
cache_clear_all
(
NULL
,
'cache_page'
);
}
/**
* Empty update to force a cache clear.
*/
function
restws_update_7002
()
{
}
restws.module
View file @
a588261a
...
...
@@ -265,7 +265,7 @@ function restws_menu_alter(&$items) {
else
{
$items
[
$menu_path
]
=
array
(
'page callback'
=>
'restws_page_callback'
,
'page arguments'
=>
array
(
$resource
),
'page arguments'
=>
array
(
$resource
,
'drupal_not_found'
),
'access callback'
=>
TRUE
,
'type'
=>
MENU_CALLBACK
,
);
...
...
@@ -284,7 +284,7 @@ function restws_menu_alter(&$items) {
else
{
$items
[
$menu_path
]
=
array
(
'page callback'
=>
'restws_page_callback'
,
'page arguments'
=>
array
(
$resource
),
'page arguments'
=>
array
(
$resource
,
'drupal_not_found'
),
'access callback'
=>
TRUE
,
'type'
=>
MENU_CALLBACK
,
);
...
...
@@ -305,7 +305,7 @@ function restws_menu_alter(&$items) {
else
{
$items
[
"
$menu_path
.
$format
"
]
=
array
(
'page callback'
=>
'restws_page_callback'
,
'page arguments'
=>
array
(
$resource
),
'page arguments'
=>
array
(
$resource
,
'drupal_not_found'
),
'access callback'
=>
TRUE
,
'type'
=>
MENU_CALLBACK
,
);
...
...
@@ -316,8 +316,17 @@ function restws_menu_alter(&$items) {
/**
* Menu page callback.
*
* @param string $resource
* The name of the resource.
* @param string $page_callback
* The page callback to pass through when the request is not handled by this
* module. If no other pre-existing callback is used, 'drupal_not_found'
* should be passed explicitly.
* @param mixed $arg1,...
* Further arguments that are passed through to the given page callback.
*/
function
restws_page_callback
(
$resource
,
$page_callback
=
NULL
)
{
function
restws_page_callback
(
$resource
,
$page_callback
)
{
// Determine the position of the resource and resource id in the path.
$resource_info
=
restws_get_resource_info
(
$resource
);
$resource_pos
=
isset
(
$resource_info
[
'menu_path'
])
?
count
(
explode
(
'/'
,
$resource_info
[
'menu_path'
]))
-
1
:
0
;
...
...
@@ -419,12 +428,9 @@ function restws_page_callback($resource, $page_callback = NULL) {
// @todo: Determine human readable URIs and redirect, if there is no
// page callback.
if
(
isset
(
$page_callback
))
{
// Further page callback arguments have been appended to our arguments.
$args
=
func_get_args
();
return
call_user_func_array
(
$page_callback
,
array_slice
(
$args
,
2
));
}
restws_terminate_request
(
'404 Not Found'
);
// Fall back to the passed $page_callback and pass through more arguments.
$args
=
func_get_args
();
return
call_user_func_array
(
$page_callback
,
array_slice
(
$args
,
2
));
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment