G
G
gitdev2018-09-26 19:10:26
symfony
gitdev, 2018-09-26 19:10:26

How to run fixtures in a specific sequence in Symfony 4?

When running the code, it gives an error:

In SymfonyFixturesLoader.php line 67:
The "App\Metrag\AppBundle\Entity\AgentReview" fixture class is trying to be loaded, but is not available. Make sure this class is defined as a service and tagged with "doctrine.fixture.orm".

use App\Metrag\AppBundle\Entity\AgentRealty;
use App\Metrag\AppBundle\Entity\AgentReview;
use Doctrine\Bundle\FixturesBundle\Fixture;

use Doctrine\Common\DataFixtures\DependentFixtureInterface;

use Doctrine\Common\Persistence\ObjectManager;

class GroupFixtures extends Fixture implements DependentFixtureInterface
{
    public function load(ObjectManager $manager)
    {
        // ...
    }

    public function getDependencies()
    {
        return array(
            #need for dependencies
            AgentFixtrue::class,
            DealTypeFixture::class,
            DistrictFixtrue::class,
            LayoutFixtrue::class,
            StateFixtrue::class,
            StatusFixtrue::class,

            #depend
            AgentReview::class,
            ComplaintFixtrue::class,
            RequestOnViewFixtrue::class,
            TypeFixtrue::class,
            RealtyFixture::class,
        );
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2019-01-08
@gitdev

The error text indicates that the problem is not in the fixture loading order, but in the service declaration for the AgentReview class.
I advise you to check that:
1. The AgentReview class is
inherited from Fixture. In this case, when using autowire, the fixtures should pick themselves up.
2. If the class is inherited from Fixture or autowire is disabled, then most likely you have a service configuration somewhere. Then you need to make sure that the "doctrine.fixture.orm" tag is specified in the service declaration for the AgentReview class

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question