SyliusResourceBundle
SyliusResourceBundle copied to clipboard
[Resource] Forms create resource objects without factories
I've initially mentioned this in Sylius/Sylius#7547 but wanted to get it out into its own ticket.
When submitting a form with no data given, the forms empty_data
closure creates the correct data object before setting data. Unfortunately, this means that for all resources implementing TranslatableInterface
, they won't have a locale injected, which is normally done by the TranslatableFactory
.
I think the AbstractResourceType
form type should receive a factory instance (maybe optional) that is then used in the forms empty_data
closure instead of relying on the Symfony default closure.
I can get started on a pull request, there's just the issue of BC breaks. If AbstractResourceType
were to require a resource factory, the constructor would have to use the following signature:
public function __construct($dataClass, FactoryInterface $factory, array $validationGroups = [])
Since this would constitute a BC break, what route should we take? We could make the factory optional and rely on new $class()
if no factory was given to avoid the BC break.
I'll give this some thought, but for now just copy/paste the code you want, and add an attribution in the comments. All totally valid under the MIT license. Leaving this issue open until I have a stronger opinion on it.
Thanks
I've extracted the executor stuff into Manifold, but the pool functionality remains in Aleph. This is probably about as far as I'll take it, but the copy/paste route remains open.