You are here

public function PaymentMethodConfigurationOperationsProvider::getOperations in Payment 8.2

Gets plugin operations.

Parameters

string $plugin_id: The ID of the plugin the operations are for.

Return value

array[] An array with the same structure as \Drupal\Core\Entity\EntityListBuilderInterface::getOperations()' return value.

Overrides PluginOperationsProviderInterface::getOperations

File

src/Plugin/Payment/Method/PaymentMethodConfigurationOperationsProvider.php, line 88

Class

PaymentMethodConfigurationOperationsProvider
Provides operations for payment methods based on config entities.

Namespace

Drupal\payment\Plugin\Payment\Method

Code

public function getOperations($plugin_id) {
  $payment_method_configuration_operations = $this->paymentMethodConfigurationListBuilder
    ->getOperations($this
    ->getPaymentMethodConfiguration($plugin_id));
  $titles = array(
    'edit' => $this
      ->t('Edit configuration'),
    'delete' => $this
      ->t('Delete configuration'),
    'enable' => $this
      ->t('Enable configuration'),
    'disable' => $this
      ->t('Disable configuration'),
  );
  $operations = [];
  foreach ($payment_method_configuration_operations as $name => $payment_method_configuration_operation) {
    if (array_key_exists($name, $titles)) {
      $operations[$name] = $payment_method_configuration_operation;
      $operations[$name]['title'] = $titles[$name];
      $operations[$name]['query']['destination'] = $this->redirectDestination
        ->get();
    }
  }
  return $operations;
}