summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfgang Ziegler // fago2016-07-13 14:19:11 (GMT)
committerWolfgang Ziegler // fago2016-07-13 14:19:11 (GMT)
commita588261a887a71203eba817f67e3c28b9a834940 (patch)
tree1338101d2930368a5ed9c2bdc72a4b81282d780c
parentb16e8a22397490c89aaf1fdf18a8227b35d2ebe8 (diff)
Improve default menu items generated for entity types that do not have any.7.x-2.6
-rw-r--r--restws.install7
-rw-r--r--restws.module26
2 files changed, 23 insertions, 10 deletions
diff --git a/restws.install b/restws.install
index 8c3872a..75784df 100644
--- a/restws.install
+++ b/restws.install
@@ -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() {
+
+}
diff --git a/restws.module b/restws.module
index 37812ba..eb91d59 100644
--- a/restws.module
+++ b/restws.module
@@ -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));
}
/**