symfony/maker-bundle

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

Open

#975 opened on Sep 21, 2021

View on GitHub
 (0 comments) (0 reactions) (0 assignees)PHP (425 forks)auto 404
Good First Issue

Repository metrics

Stars
 (3,384 stars)
PR merge metrics
 (PR metrics pending)

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