You are here

class PhoneNumberSettings in SMS Framework 8

Same name in this branch
  1. 8 src/Entity/PhoneNumberSettings.php \Drupal\sms\Entity\PhoneNumberSettings
  2. 8 src/Plugin/migrate/process/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\process\PhoneNumberSettings
  3. 8 src/Plugin/migrate/destination/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\destination\PhoneNumberSettings
Same name and namespace in other branches
  1. 2.x src/Plugin/migrate/process/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\process\PhoneNumberSettings
  2. 2.1.x src/Plugin/migrate/process/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\process\PhoneNumberSettings

Creates phone number settings for new D8 site based on D6/D7 settings.

Plugin annotation


@MigrateProcessPlugin(
  id = "phone_number_settings"
)

Hierarchy

Expanded class hierarchy of PhoneNumberSettings

File

src/Plugin/migrate/process/PhoneNumberSettings.php, line 16

Namespace

Drupal\sms\Plugin\migrate\process
View source
class PhoneNumberSettings extends ProcessPluginBase {
  const DEFAULT_D7_VERIFICATION_MESSAGE = '[site:name] confirmation code: ';
  const DEFAULT_D6_VERIFICATION_MESSAGE = '[site-name] confirmation code: [confirm-code]';
  const DEFAULT_VERIFICATION_MESSAGE = "Your verification code is '[sms-message:verification-code]'.\nGo to [sms:verification-url] to verify your phone number.\n- [site:name]";

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    if ($row
      ->getSourceProperty('id') === 'sms_user_confirmation_message') {

      // If still using the D6/D7 default message, swap for the new D8 default.
      if (empty($value) || $value == static::DEFAULT_D6_VERIFICATION_MESSAGE || $value == static::DEFAULT_D7_VERIFICATION_MESSAGE) {
        $value = static::DEFAULT_VERIFICATION_MESSAGE;
      }
      else {

        // Replace both D6 and D7 message token formats.
        $value = str_replace('[site-name]', '[site:name]', $value);
        $value = str_replace('[confirm-code]', '[sms-message:verification-code]', $value);
        $value = str_replace('[confirm:code]', '[sms-message:verification-code]', $value);
      }
    }
    return $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PhoneNumberSettings::DEFAULT_D6_VERIFICATION_MESSAGE constant
PhoneNumberSettings::DEFAULT_D7_VERIFICATION_MESSAGE constant
PhoneNumberSettings::DEFAULT_VERIFICATION_MESSAGE constant
PhoneNumberSettings::transform public function Performs the associated process. Overrides ProcessPluginBase::transform
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92
ProcessPluginBase::multiple public function Indicates whether the returned value requires multiple handling. Overrides MigrateProcessInterface::multiple 3
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.