Introduce a way to automatically create an incoming route for the plugin, similar to how it was done for the delivery reports route (#2542790: Implement API for delivery reports for SMS Gateways, #2798171: Improve route access control of delivery report URL).

Add a gateway annotation property which triggers automatic creation of a route.

Should have the same features as delivery report route generator:

  • Route
  • Callback is an optional method on gateway plugin.
  • Random unique url, url definition via gateway entity form.

Route callback

I want to investigate using the Symfony argument resolver, so that the callback method can have different parameters. The argument resolver is the service that magically gets a controllers argument values via PHP' reflection. This implementation means that we cannot use an interface, because implementors will have variable parameters.

Instead of using an interface to define a standard incoming route method, allow the gateway to define its route callbacks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpi created an issue. See original summary.

dpi’s picture

Issue tags: +release-8.x-1.0-beta2

added release-8.x-1.0-beta2 tag.

dpi’s picture

Status: Active » Needs review
FileSize
62.61 KB

The PR is ready for this issue, however the branch is based on #2832601: Incoming message handling tweaks. If you want an easy review then its best to get that issue out of the way first.

https://github.com/dpi/smsframework/pull/63

There is a good example in tests/modules/sms_test_gateway/src/Plugin/SmsGateway/Incoming.php for how plugins handle incoming requests.

Status: Needs review » Needs work

The last submitted patch, 3: incoming-route-2832862.patch, failed testing.

dpi’s picture

Status: Needs work » Needs review
FileSize
64.71 KB

Fixed some failing tests due to recent merges: incoming messages require populated result object.

dpi’s picture

I have updated documentation with information on how to implement routes using the functionality from this PR: https://www.drupal.org/node/2829020

dpi’s picture

Some of the ideas from this PR could be applied to the incoming reports endpoint as well:

  • Change \Drupal\sms\Plugin\SmsGatewayPluginInterface::parseDeliveryReports to \Drupal\sms\Plugin\SmsGateway\SmsGatewayPluginInterface::processReports
  • Change above method to a controller response / one without required arguments and interface.
  • Require response object to be created inside the above method.
  • Recycle the \Drupal\sms\SmsProcessingResponse object from this issue, adding a new g/setReports method to that object.
  • \Drupal\sms\Provider\DefaultSmsProvider::processDeliveryReport can be reworked to just take report objects, instead of needing to handle a HTTP request.
  • Add a incoming reports route specific "_route" annotation. Separates incoming reports capability annotation.

Would be done in a separate issue. Edit: #2837546: Modify callback for delivery reports to match incoming messages

dpi’s picture

Rebased PR onto mainline

dpi’s picture

almaudoh’s picture

Made some comments on the PR

dpi’s picture

Reponded to

dpi’s picture

A real example can be found in the Telstra gateway plugin.

I plan to do Clickatell, but I am waiting on their response to grant dev access.

dpi’s picture

  • dpi committed 3aba04a on 8.x-1.x
    Issue #2832862 by dpi: Added automatic incoming route creation
    
dpi’s picture

Status: Needs review » Fixed
Related issues: +#2837546: Modify callback for delivery reports to match incoming messages

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.