Creating a gateway plugin

Last updated on
20 March 2025

The documentation herein is for the legacy/deprecated v1, v2, and v3 versions of SMS Framework.

Versions 4 and later have been re-architected. New documentation can be found in Communications Framework

Equivalent documentation for creating a gateway plugin in SMS Framework v4 can be found at Implementing a custom SMS transport.

Creating a gateway plugin #

Create your plugin file at src/Plugin/SmsGateway/, namespace should be Drupal\my_module\Plugin\SmsGateway.

The gateway class must implement the \Drupal\sms\Plugin\SmsGatewayPluginInterface interface. SMS Framework includes an abstract base class to speed up plugin development. Your class can can instead extend \Drupal\sms\Plugin\SmsGatewayPluginBase.

If you are new to plugin development for Drupal 8, you may find looking at existing gateway code to be helpful. SMS Framework bundles some test-grade gateways in the sms_test_gateway submodule, in addition to the Drupal log gateway \Drupal\sms\Plugin\SmsGateway\LogGateway. A list of functional third party gateways can be found at Gateways for SMS Framework.

Plugin Annotation #

Each gateway plugin must begin with a SmsGateway annotation definition. At a minimum, SmsGateway annotations must contains id, and label properties.

/**
 * @SmsGateway(
 *   id = "my_gateway",
 *   label = @Translation("My Gateway"),
 * )
 */

See the SmsGateway annotation class (\Drupal\sms\Annotation\SmsGateway) for available annotation properties recognised by the core framework. Some third party modules may choose to add additional gateway annotation properties.

Send method #

todo

Add a plugin instance #

For every site your plugin is used, you must add a plugin instance. Go to the gateway configuration page (/admin/config/smsframework/gateways) and click the 'Add gateway' button.

If it is your first time adding an instance of the new gateway, clear the cache if it is not showing on the add gateway form.

Help improve this page

Page status: No known problems

You can: