You are here

class HostedFields in Commerce Braintree 8

Provides the HostedFields payment gateway.

Plugin annotation


@CommercePaymentGateway(
  id = "braintree_hostedfields",
  label = "Braintree (Hosted Fields)",
  display_label = "Braintree",
  forms = {
    "add-payment-method" = "Drupal\commerce_braintree\PluginForm\HostedFields\PaymentMethodAddForm",
  },
  js_library = "commerce_braintree/braintree",
  payment_method_types = {"credit_card", "paypal", "paypal_credit"},
  credit_card_types = {
    "amex", "dinersclub", "discover", "jcb", "maestro", "mastercard", "visa",
  },
  requires_billing_information = FALSE,
)

Hierarchy

Expanded class hierarchy of HostedFields

File

src/Plugin/Commerce/PaymentGateway/HostedFields.php, line 44

Namespace

Drupal\commerce_braintree\Plugin\Commerce\PaymentGateway
View source
class HostedFields extends OnsitePaymentGatewayBase implements HostedFieldsInterface {

  /**
   * The event dispatcher.
   *
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
   */
  protected $eventDispatcher;

  /**
   * The Braintree gateway used for making API calls.
   *
   * @var \Braintree\Gateway
   */
  protected $api;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_type.manager'), $container
      ->get('plugin.manager.commerce_payment_type'), $container
      ->get('plugin.manager.commerce_payment_method_type'), $container
      ->get('datetime.time'), $container
      ->get('event_dispatcher'));
  }

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, PaymentTypeManager $payment_type_manager, PaymentMethodTypeManager $payment_method_type_manager, TimeInterface $time, EventDispatcherInterface $event_dispatcher) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $payment_type_manager, $payment_method_type_manager, $time);
    $this->api = new BraintreeGateway([
      'environment' => $this
        ->getMode() == 'test' ? 'sandbox' : 'production',
      'merchantId' => $this->configuration['merchant_id'],
      'publicKey' => $this->configuration['public_key'],
      'privateKey' => $this->configuration['private_key'],
    ]);
    $this->eventDispatcher = $event_dispatcher;
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'merchant_id' => '',
      'public_key' => '',
      'private_key' => '',
      'merchant_account_id' => [],
      '3d_secure' => '',
    ] + parent::defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);
    $form['merchant_id'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Merchant ID'),
      '#default_value' => $this->configuration['merchant_id'],
      '#required' => TRUE,
    ];
    $form['public_key'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Public key'),
      '#default_value' => $this->configuration['public_key'],
      '#required' => TRUE,
    ];
    $form['private_key'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Private key'),
      '#default_value' => $this->configuration['private_key'],
      '#required' => TRUE,
    ];

    // Braintree supports multiple currencies through the use of multiple
    // merchant accounts.
    $form['merchant_account_id'] = [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Merchant account ID'),
      '#description' => $this
        ->t('Where can I find <a href="@url" target="_blank">the Merchant account ID</a>?', [
        '@url' => 'https://articles.braintreepayments.com/control-panel/important-gateway-credentials#merchant-account-id',
      ]),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    ];
    $currency_storage = $this->entityTypeManager
      ->getStorage('commerce_currency');
    foreach ($currency_storage
      ->loadMultiple() as $currency_id => $currency) {
      $merchant_account_id = NULL;
      if (isset($this->configuration['merchant_account_id'][$currency_id])) {
        $merchant_account_id = $this->configuration['merchant_account_id'][$currency_id];
      }
      $form['merchant_account_id'][$currency_id] = [
        '#type' => 'textfield',
        '#title' => $this
          ->t('Merchant account ID for @currency', [
          '@currency' => $currency
            ->label(),
        ]),
        '#size' => 30,
        '#maxlength' => 128,
        '#default_value' => $merchant_account_id,
        '#required' => TRUE,
      ];
    }
    $form['3d_secure'] = [
      '#type' => 'radios',
      '#title' => $this
        ->t('3D Secure'),
      '#options' => [
        '' => $this
          ->t('Disabled'),
        'enabled' => $this
          ->t('Enabled'),
        'required' => $this
          ->t('Required'),
      ],
      '#default_value' => $this->configuration['3d_secure'],
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);
    if (!$form_state
      ->getErrors()) {
      $values = $form_state
        ->getValue($form['#parents']);
      $this->configuration['merchant_id'] = $values['merchant_id'];
      $this->configuration['public_key'] = $values['public_key'];
      $this->configuration['private_key'] = $values['private_key'];
      $this->configuration['merchant_account_id'] = $values['merchant_account_id'];
      $this->configuration['3d_secure'] = $values['3d_secure'];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function createPaymentMethodNonce($payment_method_token) {
    return $this->api
      ->paymentMethodNonce()
      ->create($payment_method_token);
  }

  /**
   * {@inheritdoc}
   */
  public function findPaymentMethodNonce($payment_method_nonce) {
    return $this->api
      ->paymentMethodNonce()
      ->find($payment_method_nonce);
  }

  /**
   * {@inheritdoc}
   */
  public function generateClientToken() {
    return $this->api
      ->clientToken()
      ->generate();
  }

  /**
   * {@inheritdoc}
   */
  public function createPayment(PaymentInterface $payment, $capture = TRUE) {
    $this
      ->assertPaymentState($payment, [
      'new',
    ]);
    $payment_method = $payment
      ->getPaymentMethod();
    $this
      ->assertPaymentMethod($payment_method);
    $amount = $payment
      ->getAmount();
    $currency_code = $payment
      ->getAmount()
      ->getCurrencyCode();
    if (empty($this->configuration['merchant_account_id'][$currency_code])) {
      throw new InvalidRequestException(sprintf('No merchant account ID configured for currency %s', $currency_code));
    }
    $transaction_data = [
      'channel' => 'CommerceGuys_BT_Vzero',
      'merchantAccountId' => $this->configuration['merchant_account_id'][$currency_code],
      // orderId must be unique.
      'orderId' => $payment
        ->getOrderId() . '-' . $this->time
        ->getCurrentTime(),
      'amount' => $amount
        ->getNumber(),
      'options' => [
        'submitForSettlement' => $capture,
      ],
    ];
    if ($payment_method
      ->isReusable()) {
      $transaction_data['paymentMethodToken'] = $payment_method
        ->getRemoteId();
    }
    else {
      $transaction_data['paymentMethodNonce'] = $payment_method
        ->getRemoteId();
    }

    // Add metadata and extra transaction data where required.
    $event = new TransactionDataEvent($transaction_data, $payment);
    $this->eventDispatcher
      ->dispatch(BraintreeEvents::TRANSACTION_DATA, $event);
    $transaction_data = $event
      ->getTransactionData();
    try {
      $result = $this->api
        ->transaction()
        ->sale($transaction_data);
      ErrorHelper::handleErrors($result);
    } catch (BraintreeException $e) {
      ErrorHelper::handleException($e);
    }
    $next_state = $capture ? 'completed' : 'authorization';
    $payment
      ->setState($next_state);
    $payment
      ->setRemoteId($result->transaction->id);

    // @todo Find out how long an authorization is valid, set its expiration.
    $payment
      ->save();
  }

  /**
   * {@inheritdoc}
   */
  public function capturePayment(PaymentInterface $payment, Price $amount = NULL) {
    $this
      ->assertPaymentState($payment, [
      'authorization',
    ]);

    // If not specified, capture the entire amount.
    $amount = $amount ?: $payment
      ->getAmount();
    try {
      $remote_id = $payment
        ->getRemoteId();
      $decimal_amount = $amount
        ->getNumber();
      $result = $this->api
        ->transaction()
        ->submitForSettlement($remote_id, $decimal_amount);
      ErrorHelper::handleErrors($result);
    } catch (BraintreeException $e) {
      ErrorHelper::handleException($e);
    }
    $payment
      ->setState('completed');
    $payment
      ->setAmount($amount);
    $payment
      ->save();
  }

  /**
   * {@inheritdoc}
   */
  public function voidPayment(PaymentInterface $payment) {
    $this
      ->assertPaymentState($payment, [
      'authorization',
    ]);
    try {
      $remote_id = $payment
        ->getRemoteId();
      $result = $this->api
        ->transaction()
        ->void($remote_id);
      ErrorHelper::handleErrors($result);
    } catch (BraintreeException $e) {
      ErrorHelper::handleException($e);
    }
    $payment
      ->setState('authorization_voided');
    $payment
      ->save();
  }

  /**
   * {@inheritdoc}
   */
  public function refundPayment(PaymentInterface $payment, Price $amount = NULL) {
    $this
      ->assertPaymentState($payment, [
      'completed',
      'partially_refunded',
    ]);

    // If not specified, refund the entire amount.
    $amount = $amount ?: $payment
      ->getAmount();
    $this
      ->assertRefundAmount($payment, $amount);
    try {
      $remote_id = $payment
        ->getRemoteId();
      $decimal_amount = $amount
        ->getNumber();
      $result = $this->api
        ->transaction()
        ->refund($remote_id, $decimal_amount);
      ErrorHelper::handleErrors($result);
    } catch (BraintreeException $e) {
      ErrorHelper::handleException($e);
    }
    $old_refunded_amount = $payment
      ->getRefundedAmount();
    $new_refunded_amount = $old_refunded_amount
      ->add($amount);
    if ($new_refunded_amount
      ->lessThan($payment
      ->getAmount())) {
      $payment
        ->setState('partially_refunded');
    }
    else {
      $payment
        ->setState('refunded');
    }
    $payment
      ->setRefundedAmount($new_refunded_amount);
    $payment
      ->save();
  }

  /**
   * {@inheritdoc}
   */
  public function createPaymentMethod(PaymentMethodInterface $payment_method, array $payment_details) {
    $payment_method_type = $payment_method
      ->getType()
      ->getPluginId();
    $required_keys = [
      'payment_method_nonce',
    ];
    $paypal_payment_method_types = [
      'paypal',
      'paypal_credit',
    ];
    if (!in_array($payment_method_type, $paypal_payment_method_types)) {
      $required_keys += [
        'card_type',
        'last2',
      ];
    }

    // Use PaymentGatewayException instead of InvalidArgumentException to handle missing data items.
    foreach ($required_keys as $required_key) {
      if (empty($payment_details[$required_key])) {
        throw new PaymentGatewayException(sprintf('In HostedFields::createPaymentMethod(), $payment_details must contain the %s key.', $required_key));
      }
    }
    if (!$payment_method
      ->isReusable()) {
      $payment_method->card_type = $this
        ->mapCreditCardType($payment_details['card_type']);
      $payment_method->card_number = $payment_details['last2'];
      $remote_id = $payment_details['payment_method_nonce'];

      // Nonces expire after 3h. We reduce that time by 5s to account for the
      // time it took to do the server request after the JS tokenization.
      $expires = $this->time
        ->getRequestTime() + 3600 * 3 - 5;
    }
    else {
      $remote_payment_method = $this
        ->doCreatePaymentMethod($payment_method, $payment_details);
      $remote_id = $remote_payment_method['token'];
      if (in_array($payment_method_type, $paypal_payment_method_types)) {
        $payment_method->paypal_mail = $remote_payment_method['email'];
        $expires = 0;
      }
      else {
        $payment_method->card_type = $this
          ->mapCreditCardType($remote_payment_method['card_type']);
        $payment_method->card_number = $remote_payment_method['last4'];
        $payment_method->card_exp_month = $remote_payment_method['expiration_month'];
        $payment_method->card_exp_year = $remote_payment_method['expiration_year'];
        $expires = CreditCard::calculateExpirationTimestamp($remote_payment_method['expiration_month'], $remote_payment_method['expiration_year']);
      }
    }
    $payment_method
      ->setRemoteId($remote_id);
    $payment_method
      ->setExpiresTime($expires);
    $payment_method
      ->save();
  }

  /**
   * Creates the payment method on the gateway.
   *
   * @param \Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method
   *   The payment method.
   * @param array $payment_details
   *   The gateway-specific payment details.
   *
   * @return array
   *   The payment method information returned by the gateway. Notable keys:
   *   - token: The remote ID.
   *   Credit card specific keys:
   *   - card_type: The card type.
   *   - last4: The last 4 digits of the credit card number.
   *   - expiration_month: The expiration month.
   *   - expiration_year: The expiration year.
   *   PayPal specific keys:
   *   - email: The PayPal email address.
   */
  protected function doCreatePaymentMethod(PaymentMethodInterface $payment_method, array $payment_details) {
    $payment_method_type = $payment_method
      ->getType()
      ->getPluginId();
    $owner = $payment_method
      ->getOwner();

    // If the owner is anonymous, the created customer will be blank.
    // https://developers.braintreepayments.com/reference/request/customer/create/php#blank-customer
    $customer_id = NULL;
    $customer_data = [];
    if ($owner && $owner
      ->isAuthenticated()) {
      $customer_id = $this
        ->getRemoteCustomerId($owner);
      $customer_data['email'] = $owner
        ->getEmail();
    }
    $payment_method_data = [
      'paymentMethodNonce' => $payment_details['payment_method_nonce'],
      'options' => [
        'verifyCard' => TRUE,
      ],
    ];
    $billing_address_data = [];
    if ($billing_profile = $payment_method
      ->getBillingProfile()) {

      /** @var \Drupal\address\AddressInterface $address */
      $address = $billing_profile
        ->get('address')
        ->first();
      $billing_address_data = [
        'billingAddress' => [
          'firstName' => $address
            ->getGivenName(),
          'lastName' => $address
            ->getFamilyName(),
          'company' => $address
            ->getOrganization(),
          'streetAddress' => $address
            ->getAddressLine1(),
          'extendedAddress' => $address
            ->getAddressLine2(),
          'locality' => $address
            ->getLocality(),
          'region' => $address
            ->getAdministrativeArea(),
          'postalCode' => $address
            ->getPostalCode(),
          'countryCodeAlpha2' => $address
            ->getCountryCode(),
        ],
      ];
      $payment_method_data['cardholderName'] = $address
        ->getGivenName() . ' ' . $address
        ->getFamilyName();
    }
    if ($customer_id) {

      // Create a payment method for an existing customer.
      try {
        $data = $billing_address_data + $payment_method_data + [
          'customerId' => $customer_id,
        ];
        $result = $this->api
          ->paymentMethod()
          ->create($data);
        ErrorHelper::handleErrors($result);
      } catch (BraintreeException $e) {
        ErrorHelper::handleException($e);
      }
      $remote_payment_method = $result->paymentMethod;
    }
    else {

      // Create both the customer and the payment method.
      try {
        $data = $customer_data + [
          'creditCard' => $billing_address_data + $payment_method_data,
        ];
        $result = $this->api
          ->customer()
          ->create($data);
        ErrorHelper::handleErrors($result);
      } catch (BraintreeException $e) {
        ErrorHelper::handleException($e);
      }
      $remote_payment_method = $result->customer->paymentMethods[0];
      if ($owner && $owner
        ->isAuthenticated()) {
        $this
          ->setRemoteCustomerId($owner, $result->customer->id);
        $owner
          ->save();
      }
    }
    if (in_array($payment_method_type, [
      'paypal',
      'paypal_credit',
    ])) {
      return [
        'token' => $remote_payment_method->token,
        'email' => $remote_payment_method->email,
      ];
    }
    else {
      return [
        'token' => $remote_payment_method->token,
        'card_type' => $remote_payment_method->cardType,
        'last4' => $remote_payment_method->last4,
        'expiration_month' => $remote_payment_method->expirationMonth,
        'expiration_year' => $remote_payment_method->expirationYear,
      ];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function deletePaymentMethod(PaymentMethodInterface $payment_method) {

    // Delete the remote record.
    try {
      $result = $this->api
        ->paymentMethod()
        ->delete($payment_method
        ->getRemoteId());
      ErrorHelper::handleErrors($result);
    } catch (BraintreeException $e) {
      ErrorHelper::handleException($e);
    }

    // Delete the local entity.
    $payment_method
      ->delete();
  }

  /**
   * Maps the Braintree credit card type to a Commerce credit card type.
   *
   * @param string $card_type
   *   The Braintree credit card type.
   *
   * @return string
   *   The Commerce credit card type.
   */
  protected function mapCreditCardType($card_type) {
    $map = [
      'American Express' => 'amex',
      'China UnionPay' => 'unionpay',
      'Diners Club' => 'dinersclub',
      'Discover' => 'discover',
      'JCB' => 'jcb',
      'Maestro' => 'maestro',
      'MasterCard' => 'mastercard',
      'Visa' => 'visa',
    ];
    if (!isset($map[$card_type])) {
      throw new HardDeclineException(sprintf('Unsupported credit card type "%s".', $card_type));
    }
    return $map[$card_type];
  }

}

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.
HostedFields::$api protected property The Braintree gateway used for making API calls.
HostedFields::$eventDispatcher protected property The event dispatcher.
HostedFields::buildConfigurationForm public function Form constructor. Overrides OnsitePaymentGatewayBase::buildConfigurationForm
HostedFields::capturePayment public function Captures the given authorized payment. Overrides SupportsAuthorizationsInterface::capturePayment
HostedFields::create public static function Creates an instance of the plugin. Overrides PaymentGatewayBase::create
HostedFields::createPayment public function Creates a payment. Overrides SupportsStoredPaymentMethodsInterface::createPayment
HostedFields::createPaymentMethod public function Creates a payment method with the given payment details. Overrides SupportsCreatingPaymentMethodsInterface::createPaymentMethod
HostedFields::createPaymentMethodNonce public function Creates a payment method nonce. Overrides HostedFieldsInterface::createPaymentMethodNonce
HostedFields::defaultConfiguration public function Gets default configuration for this plugin. Overrides PaymentGatewayBase::defaultConfiguration
HostedFields::deletePaymentMethod public function Deletes the given payment method. Overrides SupportsStoredPaymentMethodsInterface::deletePaymentMethod
HostedFields::doCreatePaymentMethod protected function Creates the payment method on the gateway.
HostedFields::findPaymentMethodNonce public function Finds a payment method nonce. Overrides HostedFieldsInterface::findPaymentMethodNonce
HostedFields::generateClientToken public function Generates the client token. Overrides HostedFieldsInterface::generateClientToken
HostedFields::mapCreditCardType protected function Maps the Braintree credit card type to a Commerce credit card type.
HostedFields::refundPayment public function Refunds the given payment. Overrides SupportsRefundsInterface::refundPayment
HostedFields::submitConfigurationForm public function Form submission handler. Overrides PaymentGatewayBase::submitConfigurationForm
HostedFields::voidPayment public function Voids the given payment. Overrides SupportsVoidsInterface::voidPayment
HostedFields::__construct public function Constructs a new PaymentGatewayBase object. Overrides PaymentGatewayBase::__construct
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
OnsitePaymentGatewayBase::getDefaultForms protected function Gets the default payment gateway forms. Overrides PaymentGatewayBase::getDefaultForms
PaymentGatewayBase::$entityId Deprecated protected property The ID of the parent config entity.
PaymentGatewayBase::$entityTypeManager protected property The entity type manager.
PaymentGatewayBase::$minorUnitsConverter protected property The minor units converter.
PaymentGatewayBase::$parentEntity protected property The parent config entity.
PaymentGatewayBase::$paymentMethodTypes protected property The payment method types handled by the gateway.
PaymentGatewayBase::$paymentType protected property The payment type used by the gateway.
PaymentGatewayBase::$time protected property The time.
PaymentGatewayBase::assertPaymentMethod protected function Asserts that the payment method is neither empty nor expired.
PaymentGatewayBase::assertPaymentState protected function Asserts that the payment state matches one of the allowed states.
PaymentGatewayBase::assertRefundAmount protected function Asserts that the refund amount is valid.
PaymentGatewayBase::buildAvsResponseCodeLabel public function Builds a label for the given AVS response code and card type. Overrides PaymentGatewayInterface::buildAvsResponseCodeLabel 2
PaymentGatewayBase::buildPaymentOperations public function Builds the available operations for the given payment. Overrides PaymentGatewayInterface::buildPaymentOperations 1
PaymentGatewayBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies
PaymentGatewayBase::canCapturePayment public function
PaymentGatewayBase::canRefundPayment public function
PaymentGatewayBase::canVoidPayment public function
PaymentGatewayBase::collectsBillingInformation public function Gets whether the payment gateway collects billing information. Overrides PaymentGatewayInterface::collectsBillingInformation
PaymentGatewayBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
PaymentGatewayBase::getCreditCardTypes public function Gets the credit card types handled by the gateway. Overrides PaymentGatewayInterface::getCreditCardTypes
PaymentGatewayBase::getDefaultPaymentMethodType public function Gets the default payment method type. Overrides PaymentGatewayInterface::getDefaultPaymentMethodType
PaymentGatewayBase::getDisplayLabel public function Gets the payment gateway display label. Overrides PaymentGatewayInterface::getDisplayLabel
PaymentGatewayBase::getJsLibrary public function Gets the JS library ID. Overrides PaymentGatewayInterface::getJsLibrary
PaymentGatewayBase::getLabel public function Gets the payment gateway label. Overrides PaymentGatewayInterface::getLabel
PaymentGatewayBase::getMode public function Gets the mode in which the payment gateway is operating. Overrides PaymentGatewayInterface::getMode
PaymentGatewayBase::getPaymentMethodTypes public function Gets the payment method types handled by the payment gateway. Overrides PaymentGatewayInterface::getPaymentMethodTypes
PaymentGatewayBase::getPaymentType public function Gets the payment type used by the payment gateway. Overrides PaymentGatewayInterface::getPaymentType
PaymentGatewayBase::getRemoteCustomerId protected function Gets the remote customer ID for the given user.
PaymentGatewayBase::getSupportedModes public function Gets the supported modes. Overrides PaymentGatewayInterface::getSupportedModes
PaymentGatewayBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
PaymentGatewayBase::setRemoteCustomerId protected function Sets the remote customer ID for the given user.
PaymentGatewayBase::toMinorUnits public function Converts the given amount to its minor units. Overrides PaymentGatewayInterface::toMinorUnits
PaymentGatewayBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
PaymentGatewayBase::__sleep public function Overrides DependencySerializationTrait::__sleep
PaymentGatewayBase::__wakeup public function Overrides DependencySerializationTrait::__wakeup
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.
PluginWithFormsTrait::getFormClass public function
PluginWithFormsTrait::hasFormClass public function
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.