You are here

class DefaultCheckoutFlowResolver in Commerce Core 8.2

Returns the order type's default checkout flow.

Hierarchy

Expanded class hierarchy of DefaultCheckoutFlowResolver

1 string reference to 'DefaultCheckoutFlowResolver'
commerce_checkout.services.yml in modules/checkout/commerce_checkout.services.yml
modules/checkout/commerce_checkout.services.yml
1 service uses DefaultCheckoutFlowResolver
commerce_checkout.default_checkout_flow_resolver in modules/checkout/commerce_checkout.services.yml
Drupal\commerce_checkout\Resolver\DefaultCheckoutFlowResolver

File

modules/checkout/src/Resolver/DefaultCheckoutFlowResolver.php, line 11

Namespace

Drupal\commerce_checkout\Resolver
View source
class DefaultCheckoutFlowResolver implements CheckoutFlowResolverInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a new DefaultCheckoutFlowResolver object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function resolve(OrderInterface $order) {

    /** @var \Drupal\commerce_order\Entity\OrderTypeInterface $order_type */
    $order_type = $this->entityTypeManager
      ->getStorage('commerce_order_type')
      ->load($order
      ->bundle());
    $checkout_flow_id = $order_type
      ->getThirdPartySetting('commerce_checkout', 'checkout_flow', 'default');
    $checkout_flow = $this->entityTypeManager
      ->getStorage('commerce_checkout_flow')
      ->load($checkout_flow_id);
    return $checkout_flow;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultCheckoutFlowResolver::$entityTypeManager protected property The entity type manager.
DefaultCheckoutFlowResolver::resolve public function Resolves the checkout flow. Overrides CheckoutFlowResolverInterface::resolve
DefaultCheckoutFlowResolver::__construct public function Constructs a new DefaultCheckoutFlowResolver object.