本文整理汇总了PHP中Posts::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::getMessages方法的具体用法?PHP Posts::getMessages怎么用?PHP Posts::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::getMessages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
/**
* Добавляет новую должность
*/
public function addAction()
{
$result = array();
$presentPost = \Posts::findFirst("title='" . $this->request->get("title") . "'");
if ($presentPost != false) {
$result['retcode'] = 1;
$result['msgs'][] = "Посада із такою назвою вже існує!";
} else {
$namePost = new \Posts();
$namePost->title = $this->request->get("title");
if ($namePost->save() == false) {
$result['retcode'] = 2;
$result['msgs'][] = "Неможливо додати посаду \n";
foreach ($namePost->getMessages() as $message) {
$result['msgs'][] = $message + "\n";
}
} else {
$result['retcode'] = 0;
$result['id'] = $namePost->id;
$result['msgs'][] = "Нову посаду збережено";
}
}
$this->view->disable();
$this->response->setContentType('application/json', 'UTF-8');
echo json_encode($result);
}
示例2: createAction
public function createAction()
{
$post = new Posts();
$success = $post->save($this->request->getPost(), array('id_posta', 'poruka', 'created_at'));
if ($success) {
echo "Your message has been posted !";
} else {
echo "Sorry, the following problems were generated: ";
foreach ($post->getMessages() as $message) {
echo $message->getMessage(), "<br/>";
}
}
$this->view->disable();
}
示例3: 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]);
}
示例4: create
/**
* Creates a new post
*/
public function create($latitude, $longitude, $content, $user)
{
$post = new Posts();
$post->users_id = $user->id;
$post->latitude = $latitude;
$post->longitude = $longitude;
$post->content = $content;
if ($post->save()) {
return array(true, $post->toArray());
} else {
$errors = array();
foreach ($post->getMessages() as $message) {
$errors[] = (string) $message;
}
return array(false, $errors);
}
}
示例5: savePostAction
public function savePostAction()
{
$this->view->title = "Збереження посади";
$errors = array();
if ($this->request->isPost()) {
$namePost = new \Posts();
$namePost->title = $this->request->get("title");
if ($namePost->save() == false) {
echo "Неможливо додати посаду \n";
foreach ($namePost->getMessages() as $message) {
echo $message, "\n";
}
} else {
$response = new \Phalcon\Http\Response();
$response->redirect("/methodist/stafflist/posts");
return $response;
}
}
}
示例6: createAction
/**
* Creates a new post
*/
public function createAction()
{
if (!$this->request->isPost()) {
return $this->dispatcher->forward(array("controller" => "posts", "action" => "index"));
}
$post = new Posts();
$post->title = $this->request->getPost("title");
$post->body = $this->request->getPost("body");
$post->excerpt = $this->request->getPost("excerpt");
$post->published = $this->request->getPost("published");
$post->updated = $this->request->getPost("updated");
$post->pinged = $this->request->getPost("pinged");
$post->to_ping = $this->request->getPost("to_ping");
if (!$post->save()) {
foreach ($post->getMessages() as $message) {
$this->flash->error($message);
}
return $this->dispatcher->forward(array("controller" => "posts", "action" => "new"));
}
$this->flash->success("post was created successfully");
return $this->dispatcher->forward(array("controller" => "posts", "action" => "index"));
}
示例7: createAction
/**
* Creates a new post
*/
public function createAction()
{
if (!$this->request->isPost()) {
return $this->dispatcher->forward(array("controller" => "posts", "action" => "index"));
}
$post = new Posts();
$postTags = array();
$post->id = $this->request->getPost("id");
$post->tags = $postTags;
$post->users_id = $this->session->get("user_id");
$post->title = $this->request->getPost("title");
$post->body = $this->request->getPost("body");
$post->excerpt = $this->request->getPost("excerpt");
$post->pinged = $this->request->getPost("pinged");
$post->to_ping = $this->request->getPost("to_ping");
$success = $post->save();
$tags = explode(",", $this->request->getPost("tags", array("trim", "lower")));
$post->addTags($tags);
if (!$success) {
foreach ($post->getMessages() as $message) {
$this->flash->error($message);
}
return $this->dispatcher->forward(array("controller" => "posts", "action" => "new"));
}
$this->sendPings();
$this->flash->success("post was created successfully");
return $this->dispatcher->forward(array("controller" => "posts", "action" => "index"));
}