<?php
namespace ProFolio\Bundle\ProFolioBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

/**
 * ProFolio\Bundle\ProFolioBundle\Entity\CommentHistoryItem
 *
 * @ORM\Entity()
 * @ORM\HasLifecycleCallbacks()
 */
class CommentHistoryItem extends HistoryItem
{
    /**
     * @var Comment $comment
     *
     * @ORM\OneToOne(targetEntity="Comment")
     * @ORM\JoinColumn(name="comment_id", referencedColumnName="id")
     */
    private $comment;

    /**
     * @return Comment
     */
    public function getComment()
    {
        return $this->comment;
    }

    /**
     * @param Comment $comment
     */
    public function setComment(Comment $comment)
    {
        $this->comment = $comment;
    }

    /**
     * @ORM\PrePersist()
     */
    public function executePrePersist()
    {
        $this->setCreatedAt($this->comment->getCreatedAt());
    }
}
