2014-06-05 2 views
0

과 호환되어야합니다. symfony 2 응용 프로그램에 sylius 장바구니 번들을 설치했습니다. 나는 다음과 같은 예외가 카트에 제품을 가지고하려고sylius cart-bundle - FattalErrorException : ItemResolver :: resolve()가

:

FatalErrorException: Compile Error: Declaration of Lyckee\StoreBundle\Cart\ItemResolver::resolve() must be compatible with Sylius\Bundle\CartBundle\Resolver\ItemResolverInterface::resolve(Sylius\Bundle\CartBundle\Model\CartItemInterface $item, $data) in /Applications/MAMP/htdocs/Symfony/src/Lyckee/StoreBundle/Cart/ItemResolver.php line 13

내가 발견 누군가 여기 나보다 같은 문제 갖는 Sylius CartBundle Symfony2

그는이 문제에 그것을 해결을 service.yml 파일이지만 저에게 맞지 않습니다. 당신 때문에 당신이 당신이있는 그 시간에 해결 방법

public function resolve(CartItemInterface $item, Request $request) 

호출 할 때이 오류가 발생했습니다

namespace Lyckee\StoreBundle\Entity; 

use Sylius\Bundle\CartBundle\Model\CartItem as BaseCartItem; 
use Doctrine\ORM\Mapping as ORM; 
/** 
* @ORM\Table() 
* @ORM\Entity 
* @ORM\Table(name="lyckee_cart_item_1") 
*/ 
class CartItem extends BaseCartItem 
{ 
    /** 
    *@ORM\ManyToOne(targetEntity="Lyckee\StoreBundle\Entity\Product") 
    * @ORM\JoinColumn(nullable=false)) 
    */ 
    private $product; 

    /** 
    * Get product 
    * 
    * @return \Lyckee\StoreBundle\Entity\Product 
    */ 
    public function getProduct() 
    { 
     return $this->product; 
    } 
    /** 
    * Set product 
    * 
    * @param \Lyckee\StoreBundle\Entity\Product $product 
    * @return CartItem 
    */ 

    public function setProduct(\Lyckee\StoreBundle\Entity\Product $product) 
    { 
     $this->product = $product; 
    }} 

내 항목 확인자

namespace Lyckee\StoreBundle\Cart; 

use Sylius\Bundle\CartBundle\Model\CartItemInterface; 
use Sylius\Bundle\CartBundle\Resolver\ItemResolverInterface; 
use Sylius\Bundle\CartBundle\Resolver\ItemResolvingException; 
use Symfony\Component\HttpFoundation\Request; 
use Doctrine\ORM\EntityManager; 

class ItemResolver implements ItemResolverInterface 
{ 
    private $entityManager; 

    public function __construct(EntityManager $entityManager) 
    { 
     $this->entityManager = $entityManager; 
    } 

    public function resolve(CartItemInterface $item, Request $request) 
    { 
     //$productId = $request->query->get('productId'); 

     // If no product id given, or product not found, we throw exception with nice message. 
     if (!$productId || !$product = $this->getProductRepository()->find($productId)) { 
      throw new ItemResolvingException('Requested product was not found'); 
     } 

     // Assign the product to the item and define the unit price. 
     $item->setProduct($product); 
     $item->setUnitPrice($product->getPrix()); 

     // Everything went fine, return the item. 
     return $item; 
    } 

    private function getProductRepository() 
    { 
     return $this->entityManager->getRepository('LyckeeStoreBundle:Product'); 
    } 
} 

답변

0

doc 후 필요하면 그냥 "요청"을 제거해야, 업데이트 할 :

public function resolve(CartItemInterface $item, $request) 
관련 문제