Upgrading to 2.0 API Layer
This guide is meant to show examples of different scenarios that you might encounter while upgrading your JSON:API implementation from Flarum 1.x to 2.x.
API Layer From 1.x to 2.x (fof/drafts)
We will use the drafts extension as an example, the changes from this PR will be used as a reference for this section.
- The 1.x compatible version of drafts has the following for its API implementation:
- Controllers:
CreateDraftController,DeleteDraftController,ListDraftsController,ShowDraftController,UpdateDraftController,DeleteMyDraftsController. - A serializer:
DraftSerializer. - Command handlers:
CreateDraftHandler,DeleteDraftHandler,UpdateDraftHandler.
- Controllers:
- The 2.x compatible version only has the following 128 lines ApiResource class:
DraftResource.
Lets go through the process of converting the 1.x version to 2.x.