doctrine / DoctrineFixturesBundle

Symfony integration for the doctrine/data-fixtures library
MIT License
2.45k stars 202 forks source link

Support for custom purgers #307

Closed lstrojny closed 4 years ago

lstrojny commented 4 years ago

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.

greg0ire commented 4 years ago

Please add some docs

lstrojny commented 4 years ago

Please add some docs

Done

greg0ire commented 4 years ago

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

lstrojny commented 4 years ago

Still working on solving the deprecation warnings

lstrojny commented 4 years ago

Alright, here we are:

I guess we are ready to go

Thanks for the collaboration, @greg0ire

lstrojny commented 4 years ago

@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 commented 4 years ago

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

lstrojny commented 4 years ago

@SenseException done

greg0ire commented 4 years ago

Thanks @lstrojny !