Create API Handler OPS 3.5

I’m currently upgrading some plugins to work with the next LTS version 3.5.
I have a simple comments plugin that uses the restful API. However, I found no way to create an API handler :confused:

One major change is that the constructor method for the APIHandler class now needs a controller of type PKPBaseController (I guess it is the Illuminate\Routing\Controller). But the hook I used so far (Dispatcher::dispatch) only provides a response object :frowning:

Can anyone help me with this?


Hi @felixhelix , with the removal of slim framework and porting of all the API routes to laravel’s routing toolset, we haven’t introduced any functionality yet that allow plugins to add or override existing routes . Previously we have a hook APIHandler::endpoints that allow plugin to add new route but it has been removed as previous mechanism is not compatible with current implementation .

We have a proof of concept ready that allow plugins to add/override existing routes, see Allow plugins to construct and expose own API endpoints · Issue #9434 · pkp/pkp-lib · GitHub but we did not merge it to the core as we haven’t found any use case for that .

If you think there is some good use case of this feature, may be create a new feature request from and with enough support, we can merge the above proof of concept into the core . In the mean time I will discuss about it with other team member to see what their opinion on this .

Touhidur Rahman
PKP Team

1 Like

Thanks for you reply!
I added a feature request as suggested:

I hope that underscores the neccessity of such a feature. With the integration of vue.js I think it will become even more important to have such an option.