You are here

public function ShippingMethod::getPlugin in Commerce Shipping 8.2

Gets the shipping method plugin.

Return value

\Drupal\commerce_shipping\Plugin\Commerce\ShippingMethod\ShippingMethodInterface The shipping method plugin.

Overrides ShippingMethodInterface::getPlugin

File

src/Entity/ShippingMethod.php, line 119

Class

ShippingMethod
Defines the shipping method entity class.

Namespace

Drupal\commerce_shipping\Entity

Code

public function getPlugin() {

  /** @var \Drupal\commerce\Plugin\Field\FieldType\PluginItemInterface $field_item */
  $field_item = $this
    ->get('plugin')
    ->first();

  /** @var \Drupal\commerce_shipping\Plugin\Commerce\ShippingMethod\ShippingMethodInterface $plugin */
  $plugin = $field_item
    ->getTargetInstance();
  $plugin
    ->setParentEntity($this);
  return $plugin;
}