mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Use resource repository
This commit is contained in:
parent
d5f4f1e2fc
commit
9145ce70d1
2 changed files with 19 additions and 8 deletions
|
|
@ -14,6 +14,7 @@ namespace Sylius\Bundle\CartBundle\Provider;
|
||||||
use Sylius\Bundle\CartBundle\Model\CartInterface;
|
use Sylius\Bundle\CartBundle\Model\CartInterface;
|
||||||
use Sylius\Bundle\CartBundle\Storage\CartStorageInterface;
|
use Sylius\Bundle\CartBundle\Storage\CartStorageInterface;
|
||||||
use Sylius\Bundle\ResourceBundle\Manager\ResourceManagerInterface;
|
use Sylius\Bundle\ResourceBundle\Manager\ResourceManagerInterface;
|
||||||
|
use Sylius\Bundle\ResourceBundle\Repository\ResourceRepositoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default provider cart.
|
* Default provider cart.
|
||||||
|
|
@ -34,7 +35,14 @@ class CartProvider implements CartProviderInterface
|
||||||
*
|
*
|
||||||
* @var ResourceManagerInterface
|
* @var ResourceManagerInterface
|
||||||
*/
|
*/
|
||||||
protected $cartManager;
|
protected $manager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cart repository.
|
||||||
|
*
|
||||||
|
* @var ResourceRepositoryInterface
|
||||||
|
*/
|
||||||
|
protected $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cart.
|
* Cart.
|
||||||
|
|
@ -47,12 +55,14 @@ class CartProvider implements CartProviderInterface
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param CartStorageInterface $storage
|
* @param CartStorageInterface $storage
|
||||||
* @param ResourceManagerInterface $cartManager
|
* @param ResourceManagerInterface $manager
|
||||||
|
* @param ResourceRepositoryInterface $repository
|
||||||
*/
|
*/
|
||||||
public function __construct(CartStorageInterface $storage, ResourceManagerInterface $cartManager)
|
public function __construct(CartStorageInterface $storage, ResourceManagerInterface $manager, ResourceRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$this->storage = $storage;
|
$this->storage = $storage;
|
||||||
$this->cartManager = $cartManager;
|
$this->manager = $manager;
|
||||||
|
$this->repository = $repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,8 +80,8 @@ class CartProvider implements CartProviderInterface
|
||||||
return $this->cart = $cart;
|
return $this->cart = $cart;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cart = $this->cartManager->create();
|
$cart = $this->manager->create();
|
||||||
$this->cartManager->persist($cart);
|
$this->manager->persist($cart);
|
||||||
|
|
||||||
$this->setCart($cart);
|
$this->setCart($cart);
|
||||||
|
|
||||||
|
|
@ -104,6 +114,6 @@ class CartProvider implements CartProviderInterface
|
||||||
*/
|
*/
|
||||||
protected function getCartByIdentifier($identifier)
|
protected function getCartByIdentifier($identifier)
|
||||||
{
|
{
|
||||||
return $this->cartManager->find($identifier);
|
return $this->repository->get(array('id' => $identifier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@
|
||||||
<service id="sylius_cart.provider" class="%sylius_cart.provider.class%">
|
<service id="sylius_cart.provider" class="%sylius_cart.provider.class%">
|
||||||
<argument type="service" id="sylius_cart.storage" />
|
<argument type="service" id="sylius_cart.storage" />
|
||||||
<argument type="service" id="sylius_cart.manager.cart" />
|
<argument type="service" id="sylius_cart.manager.cart" />
|
||||||
|
<argument type="service" id="sylius_cart.repository.cart" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="sylius_cart.storage.session" class="%sylius_cart.storage.session.class%">
|
<service id="sylius_cart.storage.session" class="%sylius_cart.storage.session.class%">
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue