You are here

protected function CartSession::getSessionKey in Commerce Core 8.2

Gets the session key for the given cart session type.

Parameters

string $type: The cart session type.

Return value

string The session key.

Throws

\InvalidArgumentException Thrown when the given $type is unknown.

4 calls to CartSession::getSessionKey()
CartSession::addCartId in modules/cart/src/CartSession.php
Adds the given cart order ID to the session.
CartSession::deleteCartId in modules/cart/src/CartSession.php
Deletes the given cart order id from the session.
CartSession::getCartIds in modules/cart/src/CartSession.php
Gets all cart order ids from the session.
CartSession::hasCartId in modules/cart/src/CartSession.php
Checks whether the given cart order ID exists in the session.

File

modules/cart/src/CartSession.php, line 84

Class

CartSession
Default implementation of the cart session.

Namespace

Drupal\commerce_cart

Code

protected function getSessionKey($type) {
  $keys = [
    self::ACTIVE => 'commerce_cart_orders',
    self::COMPLETED => 'commerce_cart_completed_orders',
  ];
  if (!isset($keys[$type])) {
    throw new \InvalidArgumentException(sprintf('Unknown cart session type "%s".', $type));
  }
  return $keys[$type];
}