-
-
Notifications
You must be signed in to change notification settings - Fork 895
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 maker command to generate data providers/persisters #3850
Conversation
This is a really good start thanks! Maybe some improvements for later:
|
I'll look into this soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
src/Bridge/Symfony/Maker/Resources/skeleton/DataProvider.tpl.php
Outdated
Show resolved
Hide resolved
src/Bridge/Symfony/Maker/Resources/skeleton/DataProvider.tpl.php
Outdated
Show resolved
Hide resolved
I love this idea! What about asking a question related to decoration? I commonly want a data persister or data provider simply so that I can decorate the core persister/provider to add some functionality - this is mostly useful with entities. The question could be:
(if yes):
A) Foo And then... I think we wouldn't even need to ask them if they want to "decorate"/call the core persister... I would think that if you have an entity then you always would. Or, another option would be to ask:
A) Foo Then, if the class is an entity, we decorate the core entity persister. It definitely adds significant complexity... but it would also be very nice, so I wanted to at least mention the idea :). Thanks! |
9261275
to
b7b972b
Compare
2423cb8
to
32e1dbb
Compare
src/Bridge/Symfony/Maker/Resources/skeleton/DataPersister.tpl.php
Outdated
Show resolved
Hide resolved
src/Bridge/Symfony/Maker/Resources/skeleton/DataProvider.tpl.php
Outdated
Show resolved
Hide resolved
src/Bridge/Symfony/Maker/Resources/skeleton/DataPersister.tpl.php
Outdated
Show resolved
Hide resolved
updated as requested, I've also improve code coverage and rebased @dunglas |
->arrayNode('maker') | ||
->{class_exists(MakerBundle::class) ? 'canBeDisabled' : 'canBeEnabled'}() | ||
->end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->arrayNode('maker') | |
->{class_exists(MakerBundle::class) ? 'canBeDisabled' : 'canBeEnabled'}() | |
->end() | |
->arrayNode('maker') | |
->{class_exists(MakerBundle::class) ? 'canBeDisabled' : 'canBeEnabled'}() | |
->end() |
{ | ||
return 'make:data-persister'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add the getCommandDescription
static method instead of a call to setDescription
(seems new to make it lazy).
->addOption('collection-only', null, InputOption::VALUE_NONE, 'Generate only a collection data provider') | ||
->setHelp(file_get_contents(__DIR__.'/Resources/help/MakeDataProvider.txt')); | ||
|
||
$inputConfig->setArgumentAsNonInteractive('name'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using the automatic prompt for the name?
@@ -0,0 +1,5 @@ | |||
The <info>%command.name%</info> command generates a new data persister class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The <info>%command.name%</info> command generates a new data persister class. | |
The <info>%command.name%</info> command generates an API Platform data persister class. |
@@ -0,0 +1,5 @@ | |||
The <info>%command.name%</info> command generates a new data provider class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The <info>%command.name%</info> command generates a new data provider class. | |
The <info>%command.name%</info> command generates an API Platform data provider class. |
@@ -0,0 +1,47 @@ | |||
<?= "<?php\n" ?> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strict type?
use <?= $resource_full_class_name ?>; | ||
<?php endif; ?> | ||
|
||
final class <?= $class_name ?> implements ContextAwareDataPersisterInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we add the ResumableDataPersisterInterface
too by default?
@@ -1265,6 +1265,9 @@ private function getBaseContainerBuilderProphecy(array $doctrineIntegrationsToLo | |||
'api_platform.json_schema.schema_factory', | |||
'api_platform.listener.view.validate', | |||
'api_platform.listener.view.validate_query_parameters', | |||
'api_platform.maker.command.data_persister', | |||
'api_platform.maker.command.data_provider', | |||
'api_platform.mercure.listener.response.add_link_header', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'api_platform.mercure.listener.response.add_link_header', |
I love it! 😍 |
@alanpoulain feel free to continue working on this branch as @antograssiot doesn't have much time to continue! |
- Add auto complete on resource class - Options to choose to generate only item/collection data provider
Thank you very much @antograssiot! |
I had this ready since a year probably for discussion