abstract class PaymentStatusBase in Payment 8.2
Provides a base payment status.
Plugins extending this class should provide a configuration schema that extends plugin.plugin_configuration.payment_status.payment_base.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\payment\Plugin\Payment\Status\PaymentStatusBase implements ConfigurableInterface, ContainerFactoryPluginInterface, PluginFormInterface, PaymentStatusInterface uses PaymentAwareTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of PaymentStatusBase
1 file declares its use of PaymentStatusBase
- PaymentStatusBaseTest.php in tests/
src/ Unit/ Plugin/ Payment/ Status/ PaymentStatusBaseTest.php
File
- src/
Plugin/ Payment/ Status/ PaymentStatusBase.php, line 22
Namespace
Drupal\payment\Plugin\Payment\StatusView source
abstract class PaymentStatusBase extends PluginBase implements ContainerFactoryPluginInterface, PaymentStatusInterface, PluginFormInterface, ConfigurableInterface {
use PaymentAwareTrait;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* The default datetime.
*
* @var \Drupal\Core\Datetime\DrupalDateTime
*/
protected $defaultDateTime;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The payment status plugin manager.
*
* @var \Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface
*/
protected $paymentStatusManager;
/**
* Constructs a new instance.
*
* @param mixed[] $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed[] $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* @param \Drupal\payment\Plugin\Payment\Status\PaymentStatusManagerInterface $payment_status_manager
* @param \Drupal\Core\Datetime\DrupalDateTime $default_datetime
* The default datetime of the new status.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, ModuleHandlerInterface $module_handler, PaymentStatusManagerInterface $payment_status_manager, DrupalDateTime $default_datetime) {
$configuration += $this
->defaultConfiguration();
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->defaultDateTime = $default_datetime;
$this->moduleHandler = $module_handler;
$this->paymentStatusManager = $payment_status_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('module_handler'), $container
->get('plugin.manager.payment.status'), new DrupalDateTime());
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'created' => time(),
'id' => 0,
];
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function setCreated($created) {
$this->configuration['created'] = $created;
return $this;
}
/**
* {@inheritdoc}
*/
public function getCreated() {
return $this->configuration['created'];
}
/**
* {@inheritdoc}
*/
function getAncestors() {
return $this->paymentStatusManager
->getAncestors($this
->getPluginId());
}
/**
* {@inheritdoc}
*/
public function getChildren() {
return $this->paymentStatusManager
->getChildren($this
->getPluginId());
}
/**
* {@inheritdoc}
*/
function getDescendants() {
return $this->paymentStatusManager
->getDescendants($this
->getPluginId());
}
/**
* {@inheritdoc}
*/
function hasAncestor($plugin_id) {
return $this->paymentStatusManager
->hasAncestor($this
->getPluginId(), $plugin_id);
}
/**
* {@inheritdoc}
*/
function isOrHasAncestor($plugin_id) {
return $this->paymentStatusManager
->isOrHasAncestor($this
->getPluginId(), $plugin_id);
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
if ($this->moduleHandler
->moduleExists('datetime')) {
$elements['created'] = [
'#default_value' => $this->defaultDateTime,
'#required' => TRUE,
'#title' => $this
->t('Date and time'),
'#type' => 'datetime',
];
}
else {
$elements['created'] = [
'#default_value' => $this->defaultDateTime,
'#type' => 'value',
];
if ($this->currentUser
->hasPermission('administer modules')) {
$elements['created_message'] = [
'#type' => 'markup',
'#markup' => $this
->t('Enable the <a href="@url">Datetime</a> module to set the date and time of the new payment status.', [
'@url' => new Url('system.modules_list', [], [
'fragment' => 'module-datetime',
]),
]),
];
}
}
return $elements;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PaymentAwareTrait:: |
protected | property | The payment. | |
PaymentAwareTrait:: |
public | function | ||
PaymentAwareTrait:: |
public | function | ||
PaymentStatusBase:: |
protected | property | The current user. | |
PaymentStatusBase:: |
protected | property | The default datetime. | |
PaymentStatusBase:: |
protected | property | The module handler. | |
PaymentStatusBase:: |
protected | property | The payment status plugin manager. | |
PaymentStatusBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
PaymentStatusBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
PaymentStatusBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
|
PaymentStatusBase:: |
function |
Gets this payment status's ancestors. Overrides PaymentStatusInterface:: |
||
PaymentStatusBase:: |
public | function |
Gets this payment status's children. Overrides PaymentStatusInterface:: |
|
PaymentStatusBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
PaymentStatusBase:: |
public | function |
Gets the created date and time. Overrides PaymentStatusInterface:: |
|
PaymentStatusBase:: |
function |
Get this payment status's descendants. Overrides PaymentStatusInterface:: |
||
PaymentStatusBase:: |
function |
Checks if the status has a given other status as one of its ancestors.
. Overrides PaymentStatusInterface:: |
||
PaymentStatusBase:: |
function |
Checks if the status is equal to a given other status or has it one of
its ancestors. Overrides PaymentStatusInterface:: |
||
PaymentStatusBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
PaymentStatusBase:: |
public | function |
Sets the created date and time. Overrides PaymentStatusInterface:: |
|
PaymentStatusBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
PaymentStatusBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
PaymentStatusBase:: |
public | function |
Constructs a new instance. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
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. |