This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Models/Entities/CommentEntity.php

49 lines
938 B
PHP
Raw Normal View History

<?php
2014-05-05 09:36:08 +02:00
class CommentEntity extends AbstractEntity implements IValidatable
{
public $text;
public $postId;
public $commentDate;
public $commenterId;
2014-05-05 09:36:08 +02:00
public function validate()
{
//todo
}
public function getText()
{
return TextHelper::parseMarkdown($this->text);
}
public function setPost($post)
{
$this->setCache('post', $post);
$this->postId = $post->id;
}
public function setCommenter($user)
{
$this->setCache('commenter', $user);
$this->commenterId = $user ? $user->id : null;
}
public function getPost()
{
if ($this->hasCache('post'))
return $this->getCache('post');
$post = PostModel::findById($this->postId);
$this->setCache('post', $post);
return $post;
}
public function getCommenter()
{
if ($this->hasCache('commenter'))
return $this->getCache('commenter');
$user = UserModel::findById($this->commenterId, false);
$this->setCache('commenter', $user);
return $user;
}
}