FedExPluginBase.php in Commerce FedEx 8
File
src/Plugin/Commerce/FedEx/FedExPluginBase.php
View source
<?php
namespace Drupal\commerce_fedex\Plugin\Commerce\FedEx;
use Drupal\commerce_shipping\Entity\ShipmentInterface;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use NicholasCreativeMedia\FedExPHP\Structs\RequestedPackageLineItem;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class FedExPluginBase extends PluginBase implements ContainerFactoryPluginInterface, FedExPluginInterface {
use StringTranslationTrait;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
public function defaultConfiguration() {
return [];
}
public function getConfiguration() {
return $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = NestedArray::mergeDeep($this
->defaultConfiguration(), $configuration);
}
public function calculateDependencies() {
return [];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
return $form;
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
return $form;
}
public function adjustPackage(RequestedPackageLineItem $package, array $items, ShipmentInterface $shipment) {
return $package;
}
public function splitPackage(array $shipment_items, ShipmentInterface $shipment) {
return [
$shipment_items,
];
}
}