-
-
Notifications
You must be signed in to change notification settings - Fork 211
Allow fixtures loader custom implementation #510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
kshtompel
commented
Apr 15, 2025
- Allow fixtures loader custom implementation
It seems there are CI jobs failing. Please take a look at this guide for more on how to handle those. |
@greg0ire please suggest me what to do here, because I see no problem in code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I don't know... Have you tried putting this in a file that ends with .php
? Might work slightly better...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thank you. didn't get it
Let me insist on this:
|
@greg0ire thanks for the guidance. All checks are passed |
config/services.xml
Outdated
<argument type="service" id="service_container" /> | ||
</service> | ||
<service id="doctrine.fixtures.provider" alias="doctrine.fixtures.loader" /> | ||
<service id="doctrine.fixtures.loader" class="Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader" public="false" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(why) is this change necessary? Or maybe is it just a best practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As LoadDataFixturesDoctrineCommand class right now receives FixturesProvider interface not SymfonyFixturesLoader we should define it as separate service to allow it to be overridden and as it the same service as SymfonyFixturesLoader I just put alias on it for simplicity reason only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but isn't it possible for you to override doctrine.fixtures.loader
just by defining a service with that id
in your application? I think I remember doing something like that in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be overridden only if it was defined otherwise it should be a required part of bundle configuration to be set up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to what you just wrote, since doctrine.fixtures.loader
is defined, it can be overridden, so this is useless, but I feel this isn't what you mean to say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SymfonyFixturesLoader class is wider implementation then FixturesProvider interface and it is used to configure bundle, see FixturesCompilerPass and \Doctrine\Common\DataFixtures\Loader. So If you want to override doctrine.fixtures.loader you need implement additional methods in your implementation which are not defined in new interface. So as I mentioned I defined new interface and new service which is just alias for current fixtures loader implementation for simplicity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and it is used to configure bundle, see FixturesCompilerPass and \Doctrine\Common\DataFixtures\Loader.
I'm AFK until Monday, and can only access this on my phone. Please provide GitHub permalinks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated previous comment with links to repos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you changed this line, you can remove public="false"
because afaik are Symfony services private by default.
config/services.xml
Outdated
<argument type="service" id="service_container" /> | ||
</service> | ||
<service id="doctrine.fixtures.provider" alias="doctrine.fixtures.loader" /> | ||
<service id="doctrine.fixtures.loader" class="Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader" public="false" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you changed this line, you can remove public="false"
because afaik are Symfony services private by default.
Thanks @kshtompel |