commerce_inventory-8.x-1.0-alpha6/src/Entity/EntityProviderTrait.php

src/Entity/EntityProviderTrait.php
<?php

namespace Drupal\commerce_inventory\Entity;

/**
 * Provides a trait for entities that have an Inventory provider.
 *
 * @see \Drupal\user\EntityOwnerInterface
 */
trait EntityProviderTrait {

  /**
   * The loaded Inventory Provider.
   *
   * @var \Drupal\commerce_inventory\Plugin\Commerce\InventoryProvider\InventoryProviderInterface
   */
  protected $inventoryProvider;

  /**
   * {@inheritdoc}
   */
  public function getProvider() {
    if (is_null($this->inventoryProvider)) {

      $this->inventoryProvider = \Drupal::service('plugin.manager.commerce_inventory_provider')->createInstance($this->bundle());;
    }
    return $this->inventoryProvider;
  }

  /**
   * {@inheritdoc}
   */
  public function getType() {
    return $this->getProvider();
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc