Hi again,
Backstory: I was trying to modify my BlogController, spliting up our post type actions into multiple controllers (otherwise, the controllers tend to become quite large, having many different post types). Naturally, I tried adding new routes to my routing config, but these weren't properly integrated with the Wordpress rewrite system.
I saw that the Permastruct class in config/routing.php parses the Wordpress rewrites into Symfony routes (nice!). However, since the class is not located in the /src directory, I cannot autoload this in my own routing.php file... Maybe move it to src/Routing and import it into the config file?
Also, it would be great if we could configure which controllers handle certain (custom) content types. Here's a proposal:
new Permastruct($collection, '', [
'custom-post_type' => CustomController,
'post' => PostController,
'page' => PageController,
'default' => BlogController,
]);
Besides this, it would help to type-hint controller methods using some kind of bundle-exposed interface:
namespace Metabolism\WordpressBundle\Interface;
interface ControllerInterface {
function postAction(Post $post);
function archiveAction(array $posts, PaginationService $paginationService);
}
// Alternative:
interface ControllerInterface {
function show(Post $post);
function index(array $posts, PaginationService $paginationService); // or achive() / list()
}
Maybe it would be even better if these method names could be specified by the user (like [CustomController::class, 'myOwnMethod'], giving a bit more more flexibility.
Would love to hear your thoughts!
Hi again,
Backstory: I was trying to modify my
BlogController, spliting up our post type actions into multiple controllers (otherwise, the controllers tend to become quite large, having many different post types). Naturally, I tried adding new routes to my routing config, but these weren't properly integrated with the Wordpress rewrite system.I saw that the
Permastructclass inconfig/routing.phpparses the Wordpress rewrites into Symfony routes (nice!). However, since the class is not located in the/srcdirectory, I cannot autoload this in my own routing.php file... Maybe move it tosrc/Routingand import it into the config file?Also, it would be great if we could configure which controllers handle certain (custom) content types. Here's a proposal:
Besides this, it would help to type-hint controller methods using some kind of bundle-exposed interface:
Maybe it would be even better if these method names could be specified by the user (like
[CustomController::class, 'myOwnMethod'], giving a bit more more flexibility.Would love to hear your thoughts!