我有一个用Symfony2编码的应用程序。我创建了一个Account实体,并使用注释创建了一个名为AccountRepository的存储库。在AccountRepository对象中,我创建了一个函数来运行一些业务逻辑,该逻辑传递给外部供应商并在其站点上创建用户,并返回信息对我们来说,我可以将他们的用户与我们的帐户实体相关联。创建该用户的一部分包括通过信用卡令牌发送。然后,他们返回我想存储的一些有限的信用卡数据并与我们的帐户关联,因此在创建对象并插入适当的数据后,我有一个实体AccountCard,我无法从存储库请求实体管理器并保持AccountCard执行$ em变量上的print_r什么也没有显示,但我读过的所有内容都告诉我,我应该能够做到这一点。我做错了什么?
<?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();
}