mirror of
https://github.com/openvk/openvk
synced 2024-12-23 09:01:15 +03:00
Wall: Handle exception when posting a long comment
This commit is contained in:
parent
021971289d
commit
d9c04d1428
1 changed files with 12 additions and 8 deletions
|
@ -73,14 +73,18 @@ final class CommentPresenter extends OpenVKPresenter
|
|||
if(empty($this->postParam("text")) && !$photo && !$video)
|
||||
$this->flashFail("err", "Не удалось опубликовать комментарий", "Комментарий пустой или слишком большой.");
|
||||
|
||||
$comment = new Comment;
|
||||
$comment->setOwner($this->user->id);
|
||||
$comment->setModel(get_class($entity));
|
||||
$comment->setTarget($entity->getId());
|
||||
$comment->setContent($this->postParam("text"));
|
||||
$comment->setCreated(time());
|
||||
$comment->setFlags($flags);
|
||||
$comment->save();
|
||||
try {
|
||||
$comment = new Comment;
|
||||
$comment->setOwner($this->user->id);
|
||||
$comment->setModel(get_class($entity));
|
||||
$comment->setTarget($entity->getId());
|
||||
$comment->setContent($this->postParam("text"));
|
||||
$comment->setCreated(time());
|
||||
$comment->setFlags($flags);
|
||||
$comment->save();
|
||||
} catch (\LengthException $ex) {
|
||||
$this->flashFail("err", "Не удалось опубликовать комментарий", "Комментарий слишком большой.");
|
||||
}
|
||||
|
||||
if(!is_null($photo))
|
||||
$comment->attach($photo);
|
||||
|
|
Loading…
Reference in a new issue