Skip to content

Conversation

nxtpge
Copy link
Contributor

@nxtpge nxtpge commented Nov 14, 2022

The documentation leads to create a custom controller/action in order to create a custom operation.

However, API Platform provides an undocumented alternative: using the ApiPlatform\Action\PlaceholderAction which prevents to create a custom controller in order to create a custom operation.

Indeed, in complex cases, it prevents ending with a codebase overwhelmed by custom controllers which only exist because of the existence of the mandatory controller attribute.

In the long term, it could be a good idea for the Developer Experience to make this attribute optional so that API Platform uses the ApiPlatform\Action\PlaceholderAction by default.

The documentation leads to create a custom controller/action in order to create a custom operation.

However, API Platform provides an undocumented alternative: using the ApiPlatform\Action\PlaceholderAction which prevents to create a custom controller in order to create a custom operation.

Indeed, in complex cases, it prevents ending with a codebase overwhelmed by custom controllers which only exist because of the existence of the mandatory "controller" attribute.

In the long term, it could be a good idea for the Developer Experience to make this attribute optional so that API Platform uses the ApiPlatform\Action\PlaceholderAction by default.
Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we couldn't automate this in the core library directly (if no controller is set, use PlaceholderAction by default).

@alanpoulain
Copy link
Member

Would you like to make the PR in the core @nxtpge?

@alanpoulain alanpoulain merged commit 7f48f50 into api-platform:3.0 Nov 17, 2022
@alanpoulain
Copy link
Member

Thanks!

@nxtpge
Copy link
Contributor Author

nxtpge commented Nov 17, 2022

Would you like to make the PR in the core @nxtpge?

@alanpoulain Yes, thank you. I will try by myself this weekend and keep you informed if I succeed or have questions (on GitHub Discussions?).

@nxtpge nxtpge deleted the patch-5 branch November 17, 2022 20:24
@alanpoulain
Copy link
Member

Alright then! You can open the PR and ask questions on it if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants