PackageType.php in Commerce Shipping 8.2
File
src/Plugin/Commerce/PackageType/PackageType.php
View source
<?php
namespace Drupal\commerce_shipping\Plugin\Commerce\PackageType;
use Drupal\Core\Plugin\PluginBase;
use Drupal\physical\Length;
use Drupal\physical\Weight;
class PackageType extends PluginBase implements PackageTypeInterface {
protected $length;
protected $width;
protected $height;
protected $weight;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$dimensions = $plugin_definition['dimensions'];
$this->length = new Length($dimensions['length'], $dimensions['unit']);
$this->width = new Length($dimensions['width'], $dimensions['unit']);
$this->height = new Length($dimensions['height'], $dimensions['unit']);
$weight = $plugin_definition['weight'];
$this->weight = new Weight($weight['number'], $weight['unit']);
}
public function getId() {
return $this->pluginDefinition['id'];
}
public function getRemoteId() {
return $this->pluginDefinition['remote_id'];
}
public function getLabel() {
return $this->pluginDefinition['label'];
}
public function getLength() {
return $this->length;
}
public function getWidth() {
return $this->width;
}
public function getHeight() {
return $this->height;
}
public function getWeight() {
return $this->weight;
}
}