[3959b2a] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * @file |
---|
| 5 | * Hooks provided by Services for the definition of servers. |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /** |
---|
| 9 | * @addtogroup hooks |
---|
| 10 | * @{ |
---|
| 11 | */ |
---|
| 12 | |
---|
| 13 | /** |
---|
| 14 | * Identifies a server implementation to Services. |
---|
| 15 | * |
---|
| 16 | * @return |
---|
| 17 | * An associative array with the following keys. |
---|
| 18 | * |
---|
| 19 | * - name: The display name of this server. |
---|
| 20 | * - settings: an assoc array containing settings information per endpoint that this server is enabled. |
---|
| 21 | */ |
---|
| 22 | function hook_server_info() { |
---|
| 23 | return array( |
---|
| 24 | 'name' => 'REST', |
---|
| 25 | 'path' => 'rest', |
---|
| 26 | 'settings' => array( |
---|
| 27 | 'file' => array('inc', 'rest_server'), |
---|
| 28 | 'form' => '_rest_server_settings', |
---|
| 29 | 'submit' => '_rest_server_settings_submit', |
---|
| 30 | ), |
---|
| 31 | ); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * Acts on requests to the server defined in hook_server_info(). |
---|
| 36 | * |
---|
| 37 | * This is the main entry point to your server implementation. |
---|
| 38 | * Need to get some more description about the best way to implement |
---|
| 39 | * servers. |
---|
| 40 | */ |
---|
| 41 | function hook_server() { |
---|
| 42 | $endpoint_path = services_get_server_info('endpoint_path', 'services/rest'); |
---|
| 43 | $canonical_path = trim(drupal_substr($_GET['q'], drupal_strlen($endpoint_path)), '/'); |
---|
| 44 | $canonical_path = explode('/', $_GET['q']); |
---|
| 45 | $endpoint_path_count = count(explode('/', $endpoint_path)); |
---|
| 46 | for ($x = 0; $x < $endpoint_path_count; $x++) { |
---|
| 47 | array_shift($canonical_path); |
---|
| 48 | } |
---|
| 49 | $canonical_path = implode('/', $canonical_path); |
---|
| 50 | if (empty($canonical_path)) { |
---|
| 51 | return ''; |
---|
| 52 | } |
---|
| 53 | //Handle server based on $canonical_path |
---|
| 54 | } |
---|