Advertisement
adfaklsdjf

services targeted actions

Nov 12th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?php
  2. /*
  3. halp.info:
  4.  
  5. name = 'Halp me with targeted actionz!'
  6. description = I can't get it to work!
  7. core = 7.x
  8.  
  9. dependencies[] = services
  10. dependencies[] = rest_server
  11.  
  12. */
  13.  
  14. function halp_services_resources() {
  15. fpc("halp_services_resources");
  16. $services_resources = array();
  17. $resource = array(
  18. 'retrieve' => array(
  19. 'help' => "Retrieve object",
  20. 'file' => array('file' => 'module', 'module' => 'halp', 'name' => "halp"),
  21. 'callback' => '_halp_retrieve',
  22. //'access callback' => '_halp_resource_access',
  23. //'access arguments' => array('view'),
  24. 'access arguments' => array('access content'),
  25. //'access arguments append' => TRUE,
  26. 'args' => array(
  27. array(
  28. 'name' => 'gid',
  29. 'type' => 'int',
  30. 'description' => 'The object id',
  31. 'source' => array('path' => 0),
  32. ),
  33. ),
  34. ),
  35. 'targeted_actions' => array(
  36. 'halp_me' => array(
  37. 'access callback' => '_halp_resource_access',
  38. 'access arguments' => array('access content'),
  39. 'access arguments append' => TRUE, // Users should only have access to their own
  40. 'callback' => '_halp_targeted_action_halp_me',
  41. 'description' => 'asdf!',
  42. 'args' => array(
  43. 'name' => 'gid',
  44. 'optional' => FALSE,
  45. 'source' => array('path' => 0),
  46. 'type' => 'int',
  47. 'description' => t('object id'),
  48. ),
  49. ),
  50. ),
  51. );
  52.  
  53. $services_resources['halp'] = $resource;
  54.  
  55. return $services_resources;
  56. }
  57.  
  58. function _halp_targeted_action_halp_me($action, $gid) {
  59. return array("<halp_me>worked</halp_me>");
  60. }
  61.  
  62. function _halp_resource_access($arg1) {
  63. return TRUE;
  64. }
  65.  
  66. function _halp_retrieve($gid) {
  67. return array("<halp_retrieve>worked</halp_retrieve>");
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement