Database Reference
In-Depth Information
// are tags set?
if (isset($contentParams->tagstr)) {
$content->tagstr = $contentParams->tagstr;
}
$content = Content::editContent($_SESSION['username'], $content);
$app->response->headers->set('Content-Type', 'application/json');
echo json_encode($content);
})->name('edit-content');
// edit a status update
public static function editContent($username, Content $content) {
$tagstr=self::trimContentTags($content->tagstr);
$tags=explode(',', $tagstr);
$queryString = " MATCH (p:Content { contentId: {contentId} } )-[:NEXTPOST*0..]".
"-()-[:CURRENTPOST]-(user { username: {u} } ) " .
" SET p.title = {title}, p.url = {url}, p.tagstr = {tagstr}" .
" FOREACH (tagName in {tags} | " .
" MERGE (t:Tag {wordPhrase:tagName}) " .
" MERGE (p)-[:HAS]->(t) " .
" )" .
" RETURN p, {u} as username, true as owner " ;
$query = new Everyman\Neo4j\Cypher\Query(Neo4Client::client(), $queryString, array(
'contentId' => $content->contentId,
'u' => $username,
'title' => $content->title,
'url' => $content->url,
'tagstr' => $tagstr,
'tags' => $tags
));
$result = $query->getResultSet();
return self::returnMappedContent($result);
}
Deleting a Status Update
As with the “edit” option, when status updates are displayed, the current user's status updates contain a link to
“Delete” the status. Once clicked, it will ask if you want it deleted (no regrets!) and, if accepted, generate an AJAX GET
request to call the delete route and corresponding method in the Content class, shown in Listing 8-33.
The Cypher in the delete method begins by finding the user and content that will be used in the rest of the query.
In the first MATCH , you can determine if this status update is the CURRENTPOST by checking to see if it is related to a
NEXTPOST . If this relationship pattern matches, make the NEXTPOST into the CURRENTPOST with CREATE UNIQUE .
 
Search WWH ::




Custom Search