class DefaultOrderTypeResolver in Commerce Core 8.2
Returns the order type, based on order item type configuration.
Hierarchy
- class \Drupal\commerce_order\Resolver\DefaultOrderTypeResolver implements OrderTypeResolverInterface
Expanded class hierarchy of DefaultOrderTypeResolver
1 string reference to 'DefaultOrderTypeResolver'
- commerce_order.services.yml in modules/
order/ commerce_order.services.yml - modules/order/commerce_order.services.yml
1 service uses DefaultOrderTypeResolver
File
- modules/
order/ src/ Resolver/ DefaultOrderTypeResolver.php, line 11
Namespace
Drupal\commerce_order\ResolverView source
class DefaultOrderTypeResolver implements OrderTypeResolverInterface {
/**
* The order item type storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $orderItemTypeStorage;
/**
* Constructs a new DefaultOrderTypeResolver object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->orderItemTypeStorage = $entity_type_manager
->getStorage('commerce_order_item_type');
}
/**
* {@inheritdoc}
*/
public function resolve(OrderItemInterface $order_item) {
/** @var \Drupal\commerce_order\Entity\OrderItemTypeInterface $order_item_type */
$order_item_type = $this->orderItemTypeStorage
->load($order_item
->bundle());
return $order_item_type
->getOrderTypeId();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultOrderTypeResolver:: |
protected | property | The order item type storage. | |
DefaultOrderTypeResolver:: |
public | function |
Resolves the order type. Overrides OrderTypeResolverInterface:: |
|
DefaultOrderTypeResolver:: |
public | function | Constructs a new DefaultOrderTypeResolver object. |