传递给Doctrine \ ORM \ UnitOfWork :: getCollectionPersister()的参数1必须是一个数组,给定null

时间:2013-01-07 20:04:19

标签: php doctrine doctrine-orm

我的实体看起来像这样(粘贴相关部分):

user.php的

    /**
     * @ManyToMany(targetEntity="Startup", inversedBy="members", cascade={"persist"})
     * @OrderBy({"name"="ASC"})
     * @var Startup[]
     */
    private $startups;

    public function __construct($data = array()) 
    {
        $this->startups = new ArrayCollection();
        $this->joined = new DateTime("now");
        parent::__construct($data);
    }

Startup.php

    /**
     * @ManyToOne(targetEntity="User", cascade={"persist"})
     * @var User
     */
    private $founder = null;

    /**
     * @ManyToMany(targetEntity="User", mappedBy="startups", cascade={"persist"})
     * @OrderBy({"lastName" = "ASC"})
     * @var User[]
     */
    private $members;

    public function __construct($data = array())
    {
        $this->files = new ArrayCollection();
        $this->topics = new ArrayCollection();
        $this->members = new ArrayCollection();

        $this->founded = new DateTime("now");

        parent::__construct($data);
    }

现在我正在运行这些代码($ this-> identity instanceof User,$ values只是一些填充了字符串的结构,$ this-> model是EntityManager):

          $startup = new Startup();
          $startup->name = $values->name;
          $startup->founder = $this->identity;
          $this->model->persist($startup);
          $this->identity->startups[] = $startup;
          $this->model->flush();

我明白了:

  

参数1传递给Doctrine \ ORM \ UnitOfWork :: getCollectionPersister()   必须是一个数组,null给定,调用   ... /库/教义/ ORM / UnitOfWork.php   在第332行并定义

明显触发冲洗。我有什么问题?

1 个答案:

答案 0 :(得分:1)

固定。 $this->identity是个问题。 Framework将其序列化,然后进行反序列化。