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
Intializer Manager and DataFixture integration #96
Conversation
|
||
$container->setParameter('doctrine_phpcr.initialize.initializers', $initializers); | ||
$initializerManagerDef->addMethodCall('addInitializer', array( |
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.
this is a BC break (an acceptable one imo) - meaning it needs to be documented in the changelog.
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 it a BC break?
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 we no longer define the doctrine_phpcr.initialize.initializers
parameter. if somebody manually ran the initializer using this parameter, things will stop working for him.
i suggest we only change this thing in the 1.1 version to avoid troubles.
i agree with the direction this is taking. the initiializer manager makes sense to me. i think it makes sense to keep the executor in data-fixtures, so that the lib can be used without symfony bundles. what we probably should do is extend the base executor here to overwrite the constructor and the purge method, to use the initializer. initializer is a phpcr-bundle feature, changing the executor in data-fixtures would also be a violation of concerns. |
There seems to be very little value in extending the base executor, we cannot call the parent The only value might be in a testing by proxy - if we extend the data-fixtures executor here then at least it is in the class heierarchy and we are more likely to notice if it breaks (e.g. with a BC break in the API). But then it should be tested anywway. We do however extend the AbstractExecutor which has most of the logic. |
Of course the other option is to add the even dispatcher to the |
i think you would not need to overwrite the execute method, but could overwrite the purge method to do the init after parent::purge() returns. having the event manager in the executor and triggering something right before the first fixture is loaded sounds reasonable - what do other doctrines do? /cc @beberlei |
hmm, there is no |
i see that method. its in the AbstractExecutor: https://github.com/doctrine/data-fixtures/blob/master/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php#L128 if you extend PHPCRExecutor you can still overwrite that method of the base class. |
Ah yes .. ok sounds good. |
looking good to me. can you please add a changelog entry saying that fixture loading now runs the initializer and that instead of a parameter |
- Initializers now "managed" by the InitializerManager - Initializer classes added to InitializerManager by compiler pass - DataFixture Executor runs the initializers after purging
ok, changelog added, squashed and rebased... |
@@ -1,6 +1,10 @@ | |||
Changelog | |||
========= | |||
|
|||
* **2013-11-27**: [Initializer] Parmeter "doctrine_phpcr.initialize.initializers" no longer defined | |||
* Initializers are now collected using a compiler pass and injected into tne new InitializerManager |
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.
tne => the
Intializer Manager and DataFixture integration
great, thanks a lot for this cleanup! |
are you sure this is going to work in for example the sandbox? i think we now really need #97 and have to adapt the bundles. see for example https://github.com/symfony-cmf/cmf-sandbox/blob/master/src/Sandbox/MainBundle/DataFixtures/PHPCR/LoadSimpleCmsData.php#L27 - according to https://github.com/symfony-cmf/SimpleCmsBundle/blob/master/DependencyInjection/CmfSimpleCmsExtension.php#L144 this will evaluate to /cms and then we try to create the simplecms root node at /cms/simple - if we have an initializer creating an empty node at that location, fixture loading will fail. |
Ah ok, so |
there is this BC break of that initializers now are run when they where not run. we have to adapt simplecmsbundle 1.1 to either check if /cms/simple exists and delete it otherwise, or to provide an odm initializer if we implement that. |
BC Break: Yes
Doc PR: symfony-cmf/symfony-cmf-docs#337
This PR fixes the issue about the initializer not being called when loading fixtures.
data-fixtures
We can:
data-fixtures
Console looks like this:
I think we should also add a
getName
method to the initializers -- but maybe later (or rather in 1.1)