Type declarations have been added everywhere. Types extending or implementing types from this bundle need to be updated to match the new signatures.
Some classes have been marked as final
because they are not supposed to be
extended. Consider using composition instead of inheritance.
It is now mandatory to pass a ManagerRegistry
instance to the constructor of
Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand
.
- The automatic loading of fixtures in a directory (e.g.
AppBundle\DataFixtures\ORM) was removed. Instead, register
your fixture classes as services and tag them with
doctrine.fixture.orm
, like this:
# src/AppBundle/Resources/config/dataFixture.yml
services:
_defaults:
tags: ['doctrine.fixture.orm']
autowire: true # if you need dependency injection, see next bullet point
AppBundle\DataFixtures\ORM\:
resource: '../../DataFixtures/ORM/*'
This will happen automatically if you're using the Symfony 3.3
or higher default service configuration and your fixture classes
extend the normal Doctrine\Bundle\FixturesBundle\Fixture
class,
or implement the new Doctrine\Bundle\FixturesBundle\ORMFixtureInterface
.
- The base
Fixture
class no longer implementsContainerAwareInterface
and so no longer have a$this->container
property. You can manually implement this interface. Or, a better idea is to update your fixtures to use dependency injection:
class MyFixture extends Fixture
{
+ private $someService;
+ public function __construct(SomeService $someService)
+ {
+ $this->someService = $someService;
+ }
public function load(ObjectManager $manager)
{
- $this->container->get('some_service')->someMethod();
+ $this->someService->someMethod();
}
}
- The base
Fixture
class no longer implementsDependentFixtureInterface
. If you want to have agetDependencies()
method, be sure to implement this interface explicitly:
+ use Doctrine\Common\DataFixtures\DependentFixtureInterface;
- class MyFixture extends Fixture
+ class MyFixture extends Fixture implements DependentFixtureInterface