...
- Method PostApi::findAll() is to get all posts.
- Method Two method PostApi::getAppSetting() is and PostApi::getScreenSetting() are to register settings of the Post app to the Native Mobile App. Minimal code show as below:
...
Code Block |
---|
<?php namespace Apps\Posts\Api\Service; use Apps\Core_MobileApi\Adapter\MobileApp\MobileApp; use Apps\Core_MobileApi\Adapter\MobileApp\MobileAppSettingInterface; use Apps\Core_MobileApi\Api\AbstractResourceApi; use Apps\Posts\Api\Resource\PostResource; class PostApi extends AbstractResourceApi implements MobileAppSettingInterface { public function findAll($params = []) { $posts = [ new PostResource([ 'post_id' => 1, 'title' => "Post's title example", 'description' => "Post's description example", 'text' => "Post's description example" ]) ]; return $this->success($posts); } public function getAppSetting($param) { $app = new MobileApp('post' ,[ 'title'=> 'Posts', 'home_view'=>'menu', 'main_resource'=> new PostResource([]) ]); return $app; } public function getScreenSetting($param) { $screenSetting = new ScreenSetting('post', [ 'name' => 'posts' ]); return $screenSetting; } /* Keep other methods empty for implementation later */ } |
...