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

Support for custom purgers #307

Merged
merged 3 commits into from Apr 3, 2020
Merged

Support for custom purgers #307

merged 3 commits into from Apr 3, 2020

Conversation

lstrojny
Copy link
Contributor

@lstrojny lstrojny commented Mar 27, 2020

This PR allows users to specify a custom purger (as previously requested in #116).

As a user, I can register my custom purger factory, that implements createForEntityManager(?string $emName, EntityManagerInterface $em, array $excluded = [], bool $purgeWithTruncate = false) : PurgerInterface with the tag doctrine.fixtures.purger_factory and some alias and then run the command with --purger=$alias. If the ORMPurger is used --purge-exclusions, a list of tables that ought to not be purged, are supported.

@lstrojny lstrojny changed the title Custom purger Support for custom purgers Mar 27, 2020
@greg0ire
Copy link
Member

Please add some docs

@lstrojny
Copy link
Contributor Author

Please add some docs

Done

Command/LoadDataFixturesDoctrineCommand.php Outdated Show resolved Hide resolved
Command/LoadDataFixturesDoctrineCommand.php Outdated Show resolved Hide resolved
Command/LoadDataFixturesDoctrineCommand.php Outdated Show resolved Hide resolved
Resources/doc/index.rst Outdated Show resolved Hide resolved
Resources/doc/index.rst Outdated Show resolved Hide resolved
Resources/doc/index.rst Outdated Show resolved Hide resolved
Resources/doc/index.rst Outdated Show resolved Hide resolved
Tests/IntegrationTest.php Show resolved Hide resolved
@greg0ire
Copy link
Member

Please have a look at the test suite, it fails.

Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job with the commits!

@lstrojny
Copy link
Contributor Author

Still working on solving the deprecation warnings

@lstrojny
Copy link
Contributor Author

Alright, here we are:

I guess we are ready to go

Thanks for the collaboration, @greg0ire

When running the suite in 1 out of 1000 times I a previous container was incorrectly reused
@lstrojny
Copy link
Contributor Author

lstrojny commented Mar 30, 2020

@greg0ire meditating over it a bit, I've moved more responsibilities into the factory and added a warning if a user passes an unknown purger so that we are not falling back to the default factory silently.

@lstrojny
Copy link
Contributor Author

Tested this in a project and it works. Found and fixed another bug (truncate mode was not correctly passed).

Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small return type format changes in the docs.

Resources/doc/index.rst Outdated Show resolved Hide resolved
Resources/doc/index.rst Outdated Show resolved Hide resolved
Resources/doc/index.rst Outdated Show resolved Hide resolved
Custom purgers can now specified by implementing a PurgerFactory and
registering it with a tag "doctrine.fixtures.purger_factory" and
specifying an alias.

Co-Authored-By: Claudio Zizza <859964+SenseException@users.noreply.github.com>
@lstrojny
Copy link
Contributor Author

lstrojny commented Apr 1, 2020

@SenseException done

@greg0ire greg0ire merged commit 886cf2e into doctrine:master Apr 3, 2020
@greg0ire
Copy link
Member

greg0ire commented Apr 3, 2020

Thanks @lstrojny !

@greg0ire greg0ire self-assigned this Apr 3, 2020
@greg0ire greg0ire modified the milestone: 3.3.1 Apr 3, 2020
@greg0ire greg0ire added this to the 3.4.0 milestone Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants