Skip to content

Instantly share code, notes, and snippets.

@merk
Created June 4, 2011 12:08
Show Gist options
  • Save merk/1007849 to your computer and use it in GitHub Desktop.
Save merk/1007849 to your computer and use it in GitHub Desktop.
<?php
namespace ozfortress\AppBundle\Entity;
use FOS\CommentBundle\Entity\Comment as BaseComment;
use FOS\CommentBundle\Model\SignedCommentInterface;
use FOS\CommentBundle\Model\VotableCommentInterface;
use FOS\Userbundle\Model\UserInterface;
/**
* @orm:Entity
* @orm:Table(name="ozfortress_comment")
* @author Tim Nagel <[email protected]>
*/
class Comment extends BaseComment implements SignedCommentInterface, VotableCommentInterface
{
/**
* The author of this comment.
*
* @var User
* @orm:ManyToOne(targetEntity="User")
*/
protected $author;
/**
* Gets the author of this comment.
*
* @return User
*/
public function getAuthor()
{
return $this->author;
}
/**
* Sets the author of this comment.
*
* @param User $author
* @return void
*/
public function setAuthor(UserInterface $author)
{
$this->author = $author;
}
/**
* Returns the name of the author.
*
* @return string
*/
public function getAuthorName()
{
return $this->getAuthor() ? $this->getAuthor()->getUsername() : 'Anonymous';
}
/**
* The comments voting score.
*
* @orm:Column(type="integer")
* @var integer
*/
protected $score = 0;
/**
* Returns the score
* @return int
*/
public function getScore()
{
return $this->score;
}
/**
* Sets the comment score
*
* @param integer $score
* @return void
*/
public function setScore($score)
{
$this->score = intval($score);
}
/**
* The comments parent.
*
* @orm:ManyToOne(targetEntity="Comment", inversedBy="children")
* @var Comment
*/
protected $parent;
/**
* The comment children.
*
* @orm:OneToMany(targetEntity="Comment", mappedBy="parent")
* @var array of Comment
*/
protected $children;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment