2012-05-23 10 views
0

我無法啓動我的簡單Fixture,我以正確的方式安裝了該軟件包,並將2行放在autoload.php和Appkernel.php中,如here所述,並且然後,我創建我的夾具類,因爲它遵循:DoctrineFixturesBundle:LoadRubricaData :: load()中的致命錯誤

<?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

啓動它,我得到:

Fatal error: Declaration of ABCBundle\DataFixtures\ORM\LoadRubricaData::load() must be compatible with that of Doctrine\Common\DataFixtures\FixtureInterface::load() in [...]ABCBundle/DataFixtures/ORM/LoadRubricaData.php on line 10

,但如果你去看看那個界面,你可以看到它是正確的:

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

有什麼不對?

回答

0

該死,我忘了添加行

use Doctrine\Common\Persistence\ObjectManager;