Author: Hugo Briand (briand@ekino.com)
Inheritance: implements Sonata\Component\Basket\BasketFactoryInterface, implements Symfony\Component\Security\Http\Logout\LogoutHandlerInterface
 /**
  * {@inheritdoc}
  */
 public function load(CustomerInterface $customer)
 {
     $sessionBasket = parent::load($customer);
     if ($customer->getId()) {
         $basket = $this->basketManager->loadBasketPerCustomer($customer);
         if (!$basket) {
             return $sessionBasket;
         }
         $this->basketBuilder->build($basket);
         if ($sessionBasket && !$sessionBasket->isEmpty()) {
             // Retrieve elements put in session before user logged in and replace db elements with it
             $basket->setBasketElements($sessionBasket->getBasketElements());
         }
         // Clear session to avoid retaking elements from session afterwards
         $this->clearSession($customer);
         // We need to ensure that both customer & customer id are set
         $basket->setCustomer($customer);
         return $basket;
     }
     return $sessionBasket;
 }
 /**
  * {@inheritdoc}
  */
 public function load(CustomerInterface $customer)
 {
     // always clone the basket so it can be only saved by calling
     // the save method
     return clone parent::load($customer);
 }