DoctrineFixturesBundle:LoadRubricaData :: load()中的致命错误

时间:2012-05-23 07:59:05

标签: symfony doctrine-orm

我无法启动我的简单Fixture,我以正确的方式安装了bundle并将2行放在autoload.php和Appkernel.php中,如here所述,然后我创建了我的fixture类它如下:

<?php

namespace ABCBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface;
use ABCBundle\Entity\Rubrica;

class LoadRubricaData implements FixtureInterface
{
    public function load(ObjectManager $manager)
    {
        $rubrica = new Rubrica();
        $rubrica->setX("XXX");
        $manager->persist($rubrica);
        $manager->flush();
    }
}
?>

但是当我尝试使用

从CLI启动它时
  

php app / console doctrine:fixtures:load

我明白了:

  

致命错误:ABCBundle \ DataFixtures \ ORM \ LoadRubricaData :: load()声明必须与[...] ABCBundle / DataFixtures / ORM /中的Doctrine \ Common \ DataFixtures \ FixtureInterface :: load()兼容第10行的LoadRubricaData.php

但是如果你去看一下那个界面就可以看出它是正确的:

interface FixtureInterface
{
    /**
     * Load data fixtures with the passed EntityManager
     *
     * @param Doctrine\Common\Persistence\ObjectManager $manager
     */
    function load(ObjectManager $manager);
}

怎么了?

1 个答案:

答案 0 :(得分:0)

Damnit,我忘了添加行

use Doctrine\Common\Persistence\ObjectManager;