You are here

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

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
commerce_order.order_store_resolver in modules/order/commerce_order.services.yml
Drupal\commerce_order\Resolver\OrderStoreResolver

File

modules/order/src/Resolver/OrderStoreResolver.php, line 15

Namespace

Drupal\commerce_order\Resolver
View 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

Namesort descending Modifiers Type Description Overrides
OrderStoreResolver::$routeMatch protected property The route match.
OrderStoreResolver::resolve public function Resolves the store. Overrides StoreResolverInterface::resolve
OrderStoreResolver::__construct public function Constructs a new OrderStoreResolver object.