You are here

class CartStorageSelect in Basic cart 8

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

Hierarchy

Expanded class hierarchy of CartStorageSelect

1 file declares its use of CartStorageSelect
Utility.php in src/Utility.php
Contains \Drupal\basic_cart\Utility

File

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

Namespace

Drupal\basic_cart
View source
class CartStorageSelect {
  private $cart = NULL;
  private $cart_storage;
  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;
    }
  }
  public function getCart($nid = NULL) {
    return $this->cart
      ->getCart($nid);
  }
  public function removeFromCart($nid) {
    return $this->cart
      ->removeFromCart($nid);
  }
  public function emptyCart() {
    return $this->cart
      ->emptyCart();
  }
  public function addToCart($id, $params = array()) {
    return $this->cart
      ->addToCart($id, $params);
  }
  public function loggedInActionCart() {
    return $this->cart
      ->loggedInActionCart();
  }

}

Members