symfony / symfony/maker-bundle

make:entity ApiResource question not called when entity pass as an argument

Open
#975 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Good First Issue
Dominant language
PHP
Stars
3.4k
Forks
427
Avg merge
2d 22h
Merged PRs (30d)
20

Description

Described well here: https://symfonycasts.com/screencast/api-platform/api-resource#comment-5541407296

Basically, if you pass the entity class name to make:entity - e.g. bin/console make:entity CheeseListing, then it does NOT ask:

Mark this class as an API Platform resource?

The problem is that, in interact(), if the name argument is passed, we immediately return: https://github.com/symfony/maker-bundle/blob/884f10da90939612f26989fa6a789e46c1194930/src/Maker/MakeEntity.php#L97-L101

That should not happen. If the name argument is passed, then:

A) We obviously should not ask for the entity name - https://github.com/symfony/maker-bundle/blob/884f10da90939612f26989fa6a789e46c1194930/src/Maker/MakeEntity.php#L115-L119
B) We should also not ask for it here: https://github.com/symfony/maker-bundle/blob/884f10da90939612f26989fa6a789e46c1194930/src/Maker/MakeEntity.php#L104-L110
C) But we should ask about the api-resource and broadcast: https://github.com/symfony/maker-bundle/blob/884f10da90939612f26989fa6a789e46c1194930/src/Maker/MakeEntity.php#L121-L143

So basically, this if (https://github.com/symfony/maker-bundle/blob/884f10da90939612f26989fa6a789e46c1194930/src/Maker/MakeEntity.php#L99-L101) statement should not have a return... the first two sections should probably just be moved inside of it: https://github.com/symfony/maker-bundle/blob/884f10da90939612f26989fa6a789e46c1194930/src/Maker/MakeEntity.php#L103-L119

Cheers!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Maker/MakeEntity.php, especially interact(), and reproduce the behavior with bin/console make:entity CheeseListing. Verify that the entity name is not requested again while the API Platform resource question and related broadcast are still shown. Done means the argument-based command follows the intended prompts without the early return skipping them.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.