2014-10-04 12:06:50 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Entities;
|
2014-10-08 14:47:47 +02:00
|
|
|
use Szurubooru\Entities\Post;
|
|
|
|
use Szurubooru\Entities\User;
|
2014-10-04 12:06:50 +02:00
|
|
|
|
2014-10-06 21:09:19 +02:00
|
|
|
final class Comment extends Entity
|
2014-10-04 12:06:50 +02:00
|
|
|
{
|
|
|
|
private $postId;
|
|
|
|
private $userId;
|
|
|
|
private $creationTime;
|
|
|
|
private $lastEditTime;
|
|
|
|
private $text;
|
|
|
|
|
|
|
|
const LAZY_LOADER_USER = 'user';
|
|
|
|
const LAZY_LOADER_POST = 'post';
|
|
|
|
|
2014-10-05 16:19:08 +02:00
|
|
|
const META_SCORE = 'score';
|
|
|
|
|
2014-10-04 12:06:50 +02:00
|
|
|
public function getUserId()
|
|
|
|
{
|
|
|
|
return $this->userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setUserId($userId)
|
|
|
|
{
|
|
|
|
$this->userId = $userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPostId()
|
|
|
|
{
|
|
|
|
return $this->postId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPostId($postId)
|
|
|
|
{
|
|
|
|
$this->postId = $postId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreationTime()
|
|
|
|
{
|
|
|
|
return $this->creationTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCreationTime($creationTime)
|
|
|
|
{
|
|
|
|
$this->creationTime = $creationTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLastEditTime()
|
|
|
|
{
|
|
|
|
return $this->lastEditTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setLastEditTime($lastEditTime)
|
|
|
|
{
|
|
|
|
$this->lastEditTime = $lastEditTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getText()
|
|
|
|
{
|
|
|
|
return $this->text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setText($text)
|
|
|
|
{
|
|
|
|
$this->text = $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUser()
|
|
|
|
{
|
|
|
|
return $this->lazyLoad(self::LAZY_LOADER_USER, null);
|
|
|
|
}
|
|
|
|
|
2014-10-08 14:47:47 +02:00
|
|
|
public function setUser(User $user = null)
|
2014-10-04 12:06:50 +02:00
|
|
|
{
|
|
|
|
$this->lazySave(self::LAZY_LOADER_USER, $user);
|
2014-10-04 13:56:38 +02:00
|
|
|
$this->userId = $user ? $user->getId() : null;
|
2014-10-04 12:06:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPost()
|
|
|
|
{
|
|
|
|
return $this->lazyLoad(self::LAZY_LOADER_POST, null);
|
|
|
|
}
|
|
|
|
|
2014-10-08 14:47:47 +02:00
|
|
|
public function setPost(Post $post)
|
2014-10-04 12:06:50 +02:00
|
|
|
{
|
|
|
|
$this->lazySave(self::LAZY_LOADER_POST, $post);
|
|
|
|
$this->postId = $post->getId();
|
|
|
|
}
|
2014-10-05 16:19:08 +02:00
|
|
|
|
|
|
|
public function getScore()
|
|
|
|
{
|
|
|
|
return $this->getMeta(self::META_SCORE, 0);
|
|
|
|
}
|
2014-10-04 12:06:50 +02:00
|
|
|
}
|