コード例 #1
0
ファイル: Cart.php プロジェクト: voku/cart
 /**
  * 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);
 }
コード例 #2
0
 /**
  * @param IdentifierInterface $identifier
  * @return bool
  */
 public function equals(IdentifierInterface $identifier)
 {
     return $this->getValue() === $identifier->getValue();
 }
コード例 #3
0
 /**
  * @param  IdentifierInterface $identifier
  * @return bool
  */
 public function isMatch(IdentifierInterface $identifier)
 {
     return $this->primary === $identifier->getPrimary();
 }