class OrderStoreResolver in Commerce Core 8.2
Returns the order's store, when an order is present in the URL.
Ensures that the current store is always correct when viewing the order in admin pages, or going through checkout.
Hierarchy
- class \Drupal\commerce_order\Resolver\OrderStoreResolver implements StoreResolverInterface
Expanded class hierarchy of OrderStoreResolver
1 string reference to 'OrderStoreResolver'
- commerce_order.services.yml in modules/
order/ commerce_order.services.yml - modules/order/commerce_order.services.yml
1 service uses OrderStoreResolver
File
- modules/
order/ src/ Resolver/ OrderStoreResolver.php, line 15
Namespace
Drupal\commerce_order\ResolverView source
class OrderStoreResolver implements StoreResolverInterface {
/**
* The route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Constructs a new OrderStoreResolver object.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match.
*/
public function __construct(RouteMatchInterface $route_match) {
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*/
public function resolve() {
$order = $this->routeMatch
->getParameter('commerce_order');
if ($order instanceof OrderInterface) {
return $order
->getStore();
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OrderStoreResolver:: |
protected | property | The route match. | |
OrderStoreResolver:: |
public | function |
Resolves the store. Overrides StoreResolverInterface:: |
|
OrderStoreResolver:: |
public | function | Constructs a new OrderStoreResolver object. |