Beispiel #1
0
 /**
  * Unserialize the string.
  * Return false if an error occur. Check the symfony logs.
  *
  * @param string $serializedBasket
  *
  * @return Basket|bool
  */
 public function unserializeBasket($serializedBasket)
 {
     $basket = new Basket();
     $data = unserialize($serializedBasket);
     if (true === array_key_exists('products', $data)) {
         $products = $this->productRepository->retrieveByIdList($data['products']);
         $basket->setProducts($products);
     } else {
         //@todo: log error
         return false;
     }
     if (true === array_key_exists('nbPerProduct', $data)) {
         foreach ($data['nbPerProduct'] as $productId => $nb) {
             $basket->setNbProductByProductId($productId, $nb);
         }
     } else {
         //@todo: log error
         return false;
     }
     return $basket;
 }