You are here

public function CartStorageSelect::__construct in Basic cart 8

Same name and namespace in other branches
  1. 8.6 src/CartStorageSelect.php \Drupal\basic_cart\CartStorageSelect::__construct()
  2. 8.0 src/CartStorageSelect.php \Drupal\basic_cart\CartStorageSelect::__construct()
  3. 8.2 src/CartStorageSelect.php \Drupal\basic_cart\CartStorageSelect::__construct()
  4. 8.3 src/CartStorageSelect.php \Drupal\basic_cart\CartStorageSelect::__construct()
  5. 8.4 src/CartStorageSelect.php \Drupal\basic_cart\CartStorageSelect::__construct()
  6. 8.5 src/CartStorageSelect.php \Drupal\basic_cart\CartStorageSelect::__construct()

File

src/CartStorageSelect.php, line 17
Contains \Drupal\basic_cart\Utility

Class

CartStorageSelect

Namespace

Drupal\basic_cart

Code

public function __construct($user, $use_table = NULL) {
  $enable = $user
    ->id() && $use_table ? $user
    ->id() : 0;
  switch ($enable) {
    case 0:
      $this->cart = new CartSession($user);
      break;
    default:
      $cart_storage = new CartStorage();
      $this->cart = new CartTable($cart_storage, $user);
      break;
  }
}