Exemple #1
0
 /**
  * Cart constructor
  *
  * @param StorageInterface    $store
  * @param IdentifierInterface $identifier
  */
 public function __construct(StorageInterface $store, IdentifierInterface $identifier)
 {
     $this->store = $store;
     $this->identifier = $identifier;
     // Generate/retrieve identifier
     $this->id = $this->identifier->get();
     // Restore the cart from a saved version
     if (method_exists($this->store, 'restore')) {
         $this->store->restore($this->id);
     }
     // Let our storage class know which cart we're talking about
     $this->store->setIdentifier($this->id);
 }