PaymentTypeBase.php in Payment 8.2
File
src/Plugin/Payment/Type/PaymentTypeBase.php
View source
<?php
namespace Drupal\payment\Plugin\Payment\Type;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\payment\EventDispatcherInterface;
use Drupal\payment\PaymentAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class PaymentTypeBase extends PluginBase implements ContainerFactoryPluginInterface, PaymentTypeInterface, ConfigurableInterface, DependentPluginInterface {
use PaymentAwareTrait;
protected $eventDispatcher;
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EventDispatcherInterface $event_dispatcher) {
$configuration += $this
->defaultConfiguration();
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->eventDispatcher = $event_dispatcher;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('payment.event_dispatcher'));
}
public function calculateDependencies() {
return [];
}
public function defaultConfiguration() {
return [];
}
public function getConfiguration() {
return $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
function getResumeContextResponse() {
$this->eventDispatcher
->preResumeContext($this
->getPayment());
return $this
->doGetResumeContextResponse();
}
protected abstract function doGetResumeContextResponse();
}