hook_services_resources无效

时间:2013-10-01 03:37:15

标签: drupal-7

示例:这是我的服务资源挂钩样本,我正在使用drupal 7.我启用了服务模块和ctools模块。终点工作正常,但当我浏览 endpoint / commerce_rest / retrieve 时,网址无法正常工作

它返回以下异常, 异常'ServicesException',消息'找不到资源检索'。在/var/www/webui/drupal/sites/all/modules/services/includes/services.runtime.inc:359\nStack trace:\ n#0 / var / www / webui / drupal / sites / all / modules / services / servers / rest_server / includes / RESTServer.inc(83):services_error('找不到......',404)\ n#1 / var / www / webui / drupal / sites / all / modules / services / servers /rest_server/includes/RESTServer.inc(36):RESTServer-> getController()\ n#2 /var/www/webui/drupal/sites/all/modules/services/servers/rest_server/rest_server.module(40) :RESTServer-> handle()\ n#3 [内部函数]:rest_server_server()\ n#4 /var/www/webui/drupal/sites/all/modules/services/services.module(218):call_user_func( 'rest_server_ser ...')\ n#5 [内部函数]:services_endpoint_callback('commerce_rest','retrieve')\ n#6 /var/www/webui/drupal/includes/menu.inc(516):call_user_func_array( 'services_endpoi ...',数组)\ n#7 /var/www/webui/drupal/index.php(33):menu_execute_active_handler()\ n#8 {main}

function test_module_services_resources() {

   $resource = array(
      'commerce_rest' => array(
      'retrieve' => array(
        'file' => array('type' => 'inc', 'module' => 'search_service'),
        'callback' => 'test_module_search_service_results',
        'access callback' => 'search_access_callback',
        'access arguments' => array('view'),
        'access arguments append' => TRUE, 
        ),
    )
 )
);
    return $resource;
}

当我浏览网址时,不会调用此挂钩 建议会很明显..

1 个答案:

答案 0 :(得分:2)

嗨您缺少文件参数

中的文件名
function test_module_services_resources() {

 $resource = array(
  'commerce_rest' => array(
  'retrieve' => array(
    'file' => array('type' => 'inc', 'module' => 'search_service', **'name' => "you are missing this"**),
    'callback' => 'test_module_search_service_results',
    'access callback' => 'search_access_callback',
    'access arguments' => array('view'),
    'access arguments append' => TRUE, 
    ),
  )
)
);
return $resource;
}