2013-08-05 7 views
3

Symfony2로 코딩하고있는 애플리케이션이 있습니다. Account 엔티티를 생성하고 주석을 사용하여 AccountRepository라는 리포지토리를 생성했습니다. AccountRepository 객체에서 외부 공급 업체로 이동하여 자신의 사이트에 사용자를 생성하고 정보를 반환하는 비즈니스 로직을 실행하는 함수를 만들었습니다. Google에 사용자를 연결하여 계정 항목을 연결할 수 있습니다. 해당 사용자 생성의 일부로 신용 카드 토큰을 통한 전송이 포함됩니다. 그런 다음 저장소에 저장하려는 일부 제한된 신용 카드 데이터를 반환하고 계정과 연결하여 개체를 만들고 적절한 데이터를 삽입 한 후에 엔티티 AccountCard를 보유하고 있으므로 저장소에서 엔티티 관리자를 요청할 수없고 AccountCard에서 $ em 변수의 print_r은 아무것도 표시하지 않지만 읽은 모든 것은이 작업을 수행 할 수 있어야한다고 알려줍니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? EntityRepository 클래스에 종속성을 결합하는 것을 사용하기 때문에Doctrine Repository getEntityManager()는 empty를 반환합니다.

<?php 

namespace Openbridge\CommonBundle\Entity\Repository; 

use Doctrine\ORM\EntityRepository; 

use Openbridge\CommonBundle\Entity\Account as Account; 
use Openbridge\CommonBundle\Entity\AccountCard as AccountCard; 
use Openbridge\CommonBundle\Entity\AccountAddress as AccountAddress; 

/** 
* AccountRepository 
* 
* This class was generated by the Doctrine ORM. Add your own custom 
* repository methods below. 
*/ 
class AccountRepository extends EntityRepository 
{ 
    public function __construct() 
    { 

    } 

    function createVendorUser(Account $account, $userData = array()) 
    { 
     // Request new user from vendor code here. (this works) 

     $ac = new AccountCard(); 
     // setters for $ac data here. 

     // Get entity manager 
     $em = $this->getEntityManager(); 
     $em->persist($ac); 
     $em->flush(); 
    } 
+0

전체 entityRepository 코드를 요점에 게시 할 수 있습니까? 그리고 타입 힌트'array()'는 어떨까요? 나는 전에 그것을 본 적이 없다. 그것은'array $ userData = array()'가 아닌가? –

+0

여기에서 수정 한 내용은 Symfony가 Entity 주석과 우리가 사용하고있는 다른 Entity와 벤더 코드를 포함하는 기본 Repository 항목을 이미 게시 한 것 이외의 많은 코드가 실제로는 없습니다. – thenetimp

답변

4

당신은, 생성자를 제거해야합니다.

+1

멍청한 실수를하면 정말 싫어. 그 점을 지적 해 주셔서 감사합니다. – thenetimp