You are here

public function BasicDeriver::getDerivativeDefinitions in Payment 8.2

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Payment/Method/BasicDeriver.php, line 53

Class

BasicDeriver
Derives payment method plugin definitions based on configuration entities.

Namespace

Drupal\payment\Plugin\Payment\Method

Code

public function getDerivativeDefinitions($base_plugin_definition) {

  /** @var \Drupal\payment\Entity\PaymentMethodConfigurationInterface[] $payment_methods */
  $payment_methods = $this->paymentMethodConfigurationStorage
    ->loadMultiple();
  foreach ($payment_methods as $payment_method) {
    if ($payment_method
      ->getPluginId() == 'payment_basic') {

      /** @var \Drupal\payment\Plugin\Payment\MethodConfiguration\Basic $configuration_plugin */
      $configuration_plugin = $this->paymentMethodConfigurationManager
        ->createInstance($payment_method
        ->getPluginId(), $payment_method
        ->getPluginConfiguration());
      $this->derivatives[$payment_method
        ->id()] = array(
        'id' => $base_plugin_definition['id'] . ':' . $payment_method
          ->id(),
        'active' => $payment_method
          ->status(),
        'label' => $configuration_plugin
          ->getBrandLabel() ? $configuration_plugin
          ->getBrandLabel() : $payment_method
          ->label(),
        'message_text' => $configuration_plugin
          ->getMessageText(),
        'message_text_format' => $configuration_plugin
          ->getMessageTextFormat(),
        'execute_status_id' => $configuration_plugin
          ->getExecuteStatusId(),
        'capture' => $configuration_plugin
          ->getCapture(),
        'capture_status_id' => $configuration_plugin
          ->getCaptureStatusId(),
        'refund' => $configuration_plugin
          ->getRefund(),
        'refund_status_id' => $configuration_plugin
          ->getRefundStatusId(),
      ) + $base_plugin_definition;
    }
  }
  return $this->derivatives;
}