I have two separate custom modules attempting to call hook_default_services_endpoint() and install an end point. However, only one of the two end points is installed.

When I combine both end points into the same hook_default_services_endpoint() in the same module, then both end points are installed.

To recreate this issue:

Create two modules (i.e, module1 and module2).
Create two end points using the Services user interface.
Export each endpoint and place one endpoint export code in module1 in module1_default_services_endpoint() and one endpoint export code in module2 in module2_default_services_endpoint() (following the guidelines for creating endpoints in code as outlined in the Services documentation)
Revisit the Services user interface and the two service calls should be "Default" instead of normal. To further test, delete the endpoints to see if they are re-installed. Only one will come back.

Now if you copy and past module2 endpoint export code into module1's module1_default_services_endpoint() in the proper fashion, both end points will appear in the Services UI.

CommentFileSizeAuthor
#3 Screen Shot 2013-01-30 at 13.58.17.png44.58 KBroam2345

Comments

kylebrowning’s picture

Status: Active » Closed (won't fix)

This is a ctools bug.

gnugu’s picture

It works, you just must name the endpoints differently. You can use the same path, though.

function module1_default_services_endpoint() {
  $endpoints = array();

  $endpoint = new stdClass();
  $endpoint->api_version = 3;
  $endpoint->name = 'end_1';
  $endpoint->path = 'svcpath';

  .....

  // IMPORTANT!!!
  $endpoints['end_1'] = $endpoint;
  return $endpoints;
}

and another module:

function module2_default_services_endpoint() {
  $endpoints = array();

  $endpoint = new stdClass();
  $endpoint->api_version = 3;
  $endpoint->name = 'end_two';
  $endpoint->path = 'svcpath';

  .....

  // IMPORTANT!!!
  $endpoints['end_two'] = $endpoint;
  return $endpoints;
}

You will end up with two endpoints with the same path. Or you can chose different paths as well.

roam2345’s picture

Status: Closed (won't fix) » Active
StatusFileSize
new44.58 KB

The above statement is wrong see attached screen shot, the path is required to be unique.

marcingy’s picture

Status: Active » Closed (won't fix)
roam2345’s picture

Thanks! found the solution for others looking.

hook_services_endpoint_alter(&$export)

That will allow one to alter the service and append any additions.

bogdan1988’s picture

Version: 6.x-3.x-dev » 8.x-4.x-dev
Issue summary: View changes

Workaround in #2 works for me fine. Thank you gnugu.