abstract class PaymentMethodConfigurationOperationsProvider in Payment 8.2
Provides operations for payment methods based on config entities.
Hierarchy
- class \Drupal\payment\Plugin\Payment\Method\PaymentMethodConfigurationOperationsProvider implements ContainerInjectionInterface, PluginOperationsProviderInterface uses StringTranslationTrait
Expanded class hierarchy of PaymentMethodConfigurationOperationsProvider
1 file declares its use of PaymentMethodConfigurationOperationsProvider
- PaymentMethodConfigurationOperationsProviderTest.php in tests/
src/ Unit/ Plugin/ Payment/ Method/ PaymentMethodConfigurationOperationsProviderTest.php
File
- src/
Plugin/ Payment/ Method/ PaymentMethodConfigurationOperationsProvider.php, line 21
Namespace
Drupal\payment\Plugin\Payment\MethodView source
abstract class PaymentMethodConfigurationOperationsProvider implements PluginOperationsProviderInterface, ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The payment method configuration list builder.
*
* @var \Drupal\Core\Entity\EntityListBuilderInterface
*/
protected $paymentMethodConfigurationListBuilder;
/**
* The payment method configuration storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $paymentMethodConfigurationStorage;
/**
* The redirect destination.
*
* @var \Drupal\Core\Routing\RedirectDestinationInterface
*/
protected $redirectDestination;
/**
* Constructs a new instance.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translator.
* @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination
* The redirect destination.
* @param \Drupal\Core\Entity\EntityStorageInterface $payment_method_configuration_storage
* The payment method configuration storage.
* @param \Drupal\Core\Entity\EntityListBuilderInterface $payment_method_configuration_list_builder
* The payment method configuration list builder.
*/
public function __construct(TranslationInterface $string_translation, RedirectDestinationInterface $redirect_destination, EntityStorageInterface $payment_method_configuration_storage, EntityListBuilderInterface $payment_method_configuration_list_builder) {
$this->paymentMethodConfigurationListBuilder = $payment_method_configuration_list_builder;
$this->paymentMethodConfigurationStorage = $payment_method_configuration_storage;
$this->redirectDestination = $redirect_destination;
$this->stringTranslation = $string_translation;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $container
->get('entity_type.manager');
return new static($container
->get('string_translation'), $container
->get('redirect.destination'), $entity_type_manager
->getStorage('payment_method_configuration'), $entity_type_manager
->getListBuilder('payment_method_configuration'));
}
/**
* Gets the payment method configuration entity for this plugin.
*
* @param string $plugin_id
* This plugin's ID.
*
* @return \Drupal\payment\Entity\PaymentMethodConfigurationInterface
*/
protected abstract function getPaymentMethodConfiguration($plugin_id);
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentMethodConfigurationOperationsProvider:: |
protected | property | The payment method configuration list builder. | |
PaymentMethodConfigurationOperationsProvider:: |
protected | property | The payment method configuration storage. | |
PaymentMethodConfigurationOperationsProvider:: |
protected | property | The redirect destination. | |
PaymentMethodConfigurationOperationsProvider:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
PaymentMethodConfigurationOperationsProvider:: |
public | function |
Gets plugin operations. Overrides PluginOperationsProviderInterface:: |
|
PaymentMethodConfigurationOperationsProvider:: |
abstract protected | function | Gets the payment method configuration entity for this plugin. | 1 |
PaymentMethodConfigurationOperationsProvider:: |
public | function | Constructs a new instance. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |