PaymentLineItemBase.php in Payment 8.2
File
src/Plugin/Payment/LineItem/PaymentLineItemBase.php
View source
<?php
namespace Drupal\payment\Plugin\Payment\LineItem;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\payment\PaymentAwareTrait;
abstract class PaymentLineItemBase extends PluginBase implements PaymentLineItemInterface, ConfigurableInterface, DependentPluginInterface {
use PaymentAwareTrait;
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
$configuration += $this
->defaultConfiguration();
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
public function calculateDependencies() {
return [];
}
public function defaultConfiguration() {
return array(
'name' => NULL,
'quantity' => 1,
);
}
public function getConfiguration() {
return $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
function getTotalAmount() {
return bcmul($this
->getAmount(), $this
->getQuantity(), 6);
}
public function setName($name) {
$this->configuration['name'] = $name;
return $this;
}
public function getName() {
return $this->configuration['name'];
}
public function setQuantity($quantity) {
$this->configuration['quantity'] = $quantity;
return $this;
}
public function getQuantity() {
return $this->configuration['quantity'];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return [];
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
}