Saturday 3 March 2012

Handling the doctrine-fixtures interface update error

Got the following error after updating doctrine-fixtures:
Fatal error: Declaration of Translator\GFBundle\DataFixtures\ORM\StatementTranslationFixtures::load() must be compatible with that of Doctrine\Common\DataFixtures\FixtureInterface::load()

It turns out that doctrine-fixtures changed their interface for the load function from:
 interface FixtureInterface
    {
        load($manager);
    }


To:
use Doctrine\Common\Persistence\ObjectManager;

    interface FixtureInterface
    {
        load(ObjectManager $manager);
    }



... as seen in the included text file named "UPGRADE".


Solution:


To update your fixture files, simply add the "use" line in your fixtures file, and change all of your load() functions to include the ObjectManager bit.


Example:


... (other use statements) ...
load($manager){
  ... (code to load stuff ) ...
}


To:
... (other use statements) ...
use Doctrine\Common\Persistence\ObjectManager;

load(ObjectManager $manager){
  ... (code to load stuff) ...
}

No comments:

Post a Comment