Skip to content

[Question] How to refer an object from native Doctrine fixtures? #1237

@TomasVotruba

Description

@TomasVotruba

Hi, I'm doing a huge migration of old forked Alice/Fixture/Hautelook/Faker packages (total mess).

We use native Doctrine PHP fixtures, where we set a reference:

$this->addReference('pretty-car', $car);

We use these object further in Alice fixture, where we fetch them from database (not sure why).

I want use reference in Alice to avoid calling database, as we normally do:

App\Entity\User:
    tom:
        car: "@pretty-car"

But this doesn't work. Any way how to make it happen?

I've noticed there is a \Doctrine\Common\DataFixtures\ReferenceRepository that collects all references, but not sure how/where to inject it into Alice, so Alice can fetch referenced objects from there.


Thank you 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions