Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Tutorial 5: Show Post on Detail Screen

Tutorial 5: Show Post on Detail Screen

When clicking on an item in the Home App screen, it navigates to a detail screen. And display data response from Detail Resource API
Detail Resource API pattern: "url/restful_api/mobile/post/post_id?access_token=token"
Logic code of the API implements in method findOne() of PostApi class. ID parameter resolves automatically. The resolver instance is a helper class help to extract or validate parameters from the request.
PostApi.php
class PostApi extends AbstractResourceApi implements MobileAppSettingInterface
{
/.../
public function findOne($params)
{
$id = $this->resolver->resolveId($params);
// Todo: Loading data form database and build as resource
$post = new PostResource([
'post_id' => $id,
'title' => "Post's title example " . $id,
'description' => "Post's description " . $id,
'text' => "Post's Full Text " .$id
]);
return $this->success($post);
}
}
 
The result of the detail screen as following
 
 

  • No labels