symfony/maker-bundle

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

Open

#975 aperta il 21 set 2021

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)PHP (425 fork)auto 404
Good First Issue

Metriche repository

Star
 (3384 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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!

Guida contributor