Skip to content
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

Add documentation for auto primary key doctrine generators #62

Merged
merged 2 commits into from
Oct 29, 2017

Conversation

theofidry
Copy link
Owner

Closes #40

@theofidry theofidry merged commit 880ec0e into master Oct 29, 2017
@theofidry theofidry deleted the doc/auto-pk-generator branch October 29, 2017 17:55
@umpirsky
Copy link

umpirsky commented Apr 4, 2018

Is it possible to override ID generator for all entities at once (instead of doing it on per entity basis)?

@theofidry
Copy link
Owner Author

As it's done automatically, if you set the ID for all entities then the ID generator will be overridden for all

@umpirsky
Copy link

umpirsky commented Apr 4, 2018

I don't want to set ID, but ID generator, like:

$dummyMetadata = $this->manager->getMetadataFactory()->getMetadataFor(Dummy::class);

// Disable the auto generation of the foreign key
$dummyMetadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$dummyMetadata->setIdGenerator(new MyIdGenerator());

But not only for Dummy::class, I want to do that for all entities.

@theofidry
Copy link
Owner Author

oh, yeah not out of the box. But you should be able to easily overwrite the existing persister loader to do that. Maybe it can be refactored a bit to make it easier

@umpirsky
Copy link

umpirsky commented Apr 4, 2018

This PersisterLoader? How? It's @final BTW. :)

@theofidry
Copy link
Owner Author

Actually overriding https://github.com/theofidry/AliceDataFixtures/blob/master/src/Bridge/Doctrine/Persister/ObjectManagerPersister.php seems more correct. You can override it by creating your own class and registering a service with the same ID.

@final tags are here to say this was not intended to be extended. But it can be removed if the use case is valid, I just do this by default to ease the refactoring.

@umpirsky
Copy link

umpirsky commented Apr 4, 2018

Thanks @theofidry!

Do you think that making ORMAssignedGenerator a service and injecting it into ObjectManagerPersister would make sense? It would ease overriding. I can submit PR if you are willing to merge such contrib?

@umpirsky
Copy link

umpirsky commented Apr 5, 2018

@theofidry This makes it even harder to override.

@theofidry
Copy link
Owner Author

Do you think that making ORMAssignedGenerator a service and injecting it into ObjectManagerPersister would make sense? It would ease overriding. I can submit PR if you are willing to merge such contrib?

that or making the persister extendable and putting some logic in a method to make it easy to override. I'm fine either way.

This makes it even harder to override.

Indeed this should be in a factory instead :/

@umpirsky
Copy link

umpirsky commented Apr 6, 2018

Fixed in #91. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants