本文整理汇总了PHP中Posts::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::create方法的具体用法?PHP Posts::create怎么用?PHP Posts::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
public function createAction()
{
$entity = new \Posts();
$createForm = new AutoForm($entity);
if ($this->request->isPost()) {
$created = $entity->create($this->request->getPost());
if (!$created) {
foreach ($entity->getMessages() as $message) {
$this->flashSession->error($message);
}
}
return $this->dispatcher->forward(['action' => 'index']);
}
$this->view->setVars(['testForm' => $createForm]);
}
示例2: function
$app->get('/post/{id}', function ($request, $response, $args) {
$token = parseToken($request);
$post_id = $args['id'];
return Posts::get($response, $token, $post_id);
});
/* Handle delete post */
$app->delete('/post/{id}', function ($request, $response, $args) {
$token = parseToken($request);
$post_id = $args['id'];
return Posts::delete($response, $token, $post_id);
});
/* Handle insert post */
$app->post('/post/', function ($request, $response, $args) {
$token = parseToken($request);
$data = parseJsonBody($request);
return Posts::create($response, $token, $data);
});
/* Handle get home posts */
$app->get('/post/', function ($request, $response) {
$token = parseToken($request);
return Posts::home($response, $token);
});
/* Handle get my blocked friends */
$app->get('/user/me/friends/blocked', function ($request, $response) {
$token = parseToken($request);
return Friends::blocked($response, $token);
});
/* Handle block friend */
$app->post('/user/{id:[0-9]+}/block', function ($request, $response, $args) {
$token = parseToken($request);
$friend_id = $args['id'];