Database Reference
In-Depth Information
Figure 8-11. Editing a status update
As with the add feature, the edit feature will use a route as well as a function in graphstory.js , which are edit
and editContent , respectively. The edit content route passes in the content object, with its content id, and then calls
the editContent method in Content class, as shown in Listing 8-32.
In the case of the edit feature, we will not need to update relationships. Instead, simply retrieve the existing node
by its generated String Id (not its graph id), update its properties where necessary, and save it back to the graph.
Listing 8-32. Edit Route and Method for a Status Update
// edit a status update - route
$app->put('/posts/edit', function() use ($app){
$request = $app->request();
$contentParams = json_decode($request->getBody());
$content = Content::getStatusUpdate(
$contentParams->contentId,
$_SESSION['username']
);
$content = $content[0];
$content->title=$contentParams->title;
$content->url=$contentParams->url;
 
Search WWH ::




Custom Search