-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
API Platform support: add an --api-resource flag for the make:entity command #178
Conversation
Ignoring your question about testing for a moment, I don't like the |
Or, the option AND automatically asking if the flag isn’t passed and API Platform is installed |
@weaverryan done |
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.
One minor comment. And, we should add a test for this. In FunctionalTest
, I would duplicate the entity_new
test case that's inside getCommandEntityTests()
. There, we can add api
as a dependency (so it gets installed) and then interactively answer the new question. To be extra sure, by adding the ->assert(function (string $output, string $directory) {
to the test case, you could check the new file for the annotation.
$value = $io->askQuestion($question); | ||
|
||
$input->setOption('api-resource', $value); | ||
} |
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.
We should only ask this question when the entity does NOT exist yet. Unfortunately, that means we'll need to duplicate a bit of logic from generate()
up here:
$entityClassDetails = $generator->createClassNameDetails(
$input->getArgument('name'),
'Entity\\'
);
$classExists = class_exists($entityClassDetails->getFullName());
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.
Fixed in d003a48 (with some more Voodoo...)
Tests added. I also transformed IMO we should also remove the |
Thank you @dunglas! |
… make:entity command (dunglas) This PR was squashed before being merged into the 1.0-dev branch (closes #178). Discussion ---------- API Platform support: add an --api-resource flag for the make:entity command This PR adds a new `--api-resource` flag to the `make:entity` command. It allows to automatically a REST endpoint with CRUD operations for the given resource class using API Platform: ![screencast](https://user-images.githubusercontent.com/57224/39909149-c6c386e6-54f1-11e8-83a2-bfcd10f5ed39.gif) I need some guidance about how to add test for this (actually, a few tests are red locally on my Mac even on master). Fixes #175. Commits ------- 1c8cf9a Make the Generator class a service 3d2918a Add a functional test e6ad344 Check if the class exists ae7c296 Add an interactive question 37b3b9c API Platform support: add an --api-resource flag for the make:entity command
This PR adds a new
--api-resource
flag to themake:entity
command. It allows to automatically a REST endpoint with CRUD operations for the given resource class using API Platform:I need some guidance about how to add test for this (actually, a few tests are red locally on my Mac even on master).
Fixes #175.