Argument Resolvers
Would be nice to have https://symfony.com/doc/current/controller/value_resolver.html for commands:
public function __invoke(
#[Argument]
User $user,
) {
What do you think the argument parameters should be to do that mapping? That is, if I want to look up a user by email, how should that mapping happen?
public function __invoke(
#[Argument(name: 'email']
User $user,
#[Option(name: 'projectCode', alias: 'p', map: ['projectCode' => 'code']
Project $project,
) {
bin/console app:create-project-admin [email protected] -p bobsProject
I think this would be great, I have a lot of boilerplate code that is just mapping from an argument or option string to an entity.
Yeah something like that! Primary key by default I guess
Some of this packages features are now in 7.3: https://symfony.com/blog/new-in-symfony-7-3-invokable-commands-and-input-attributes with hopefully argument resolvers coming soon!
Argument resolver would rock! In the meantime, for the command generator I've been working on we're looking at how to inject the property entity repository and do the lookup.
I wish Symfony's make:entity did not generate an auto-increment primary key by default. In many cases, there's a field available for the PK. I've toyed with a custom generator that allows the developer to decide auto-increment or a field (ISBN, SSN, code, wikiCode, etc)