metabolism / wordpress-bundle

Use Wordpress and Symfony together using a Symfony bundle
MIT License
59 stars 17 forks source link

Catch-all controller action for custom post types #38

Open markeasting opened 11 months ago

markeasting commented 11 months ago

Hi Jerome,

Currently we have a minor issue with creating new post types, where we have to specify a new <myPostType>Action() in BlogController. Oftentimes, the methods are exactly the same, simply loading our single.html.twig template.

Would it be possible to add a catch-all method for custom post types? It would greatly reduce duplicate code in our blog controller. I guess this is also closely related to #37.

PS. thanks for creating this bundle, we're having a great time developing our CMS without having the messy project structure of Wordpress :ok_hand:

jerome-barbato commented 11 months ago

Hi @markeasting, that's an interesting point, but as dealing with case #37 is not an easy task. Currently, when I encounter this situation, I create a genericAction, and in each Action(), I simply return the genericAction. While it may not be the most elegant solution, I've done some research and couldn't find a more straightforward way to achieve this using pure Symfony... but I will keep trying !