Skip to content

Instantly share code, notes, and snippets.

@ineersa
Created February 6, 2014 21:37
Show Gist options
  • Save ineersa/8852973 to your computer and use it in GitHub Desktop.
Save ineersa/8852973 to your computer and use it in GitHub Desktop.
<?php
// src/Blogger/BlogBundle/Entity/Comment.php
namespace Blogger\BlogBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Blogger\BlogBundle\Entity\Repository\CommentRepository")
* @ORM\Table(name="comment")
* @ORM\HasLifecycleCallbacks
*/
class Comment
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $user;
/**
* @ORM\Column(type="text")
*/
protected $comment;
/**
* @ORM\Column(type="boolean")
*/
protected $approved;
/**
* @ORM\ManyToOne(targetEntity="Blog", inversedBy="comments")
* @ORM\JoinColumn(name="blog_id", referencedColumnName="id")
*/
protected $blog;
/**
* @ORM\Column(type="datetime")
*/
protected $created;
/**
* @ORM\Column(type="datetime")
*/
protected $updated;
public function __construct()
{
$this->setCreated(new \DateTime());
$this->setUpdated(new \DateTime());
$this->setApproved(true);
}
/**
* @ORM\preUpdate
*/
public function setUpdatedValue()
{
$this->setUpdated(new \DateTime());
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set user
*
* @param string $user
* @return Comment
*/
public function setUser($user)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return string
*/
public function getUser()
{
return $this->user;
}
/**
* Set comment
*
* @param string $comment
* @return Comment
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set approved
*
* @param boolean $approved
* @return Comment
*/
public function setApproved($approved)
{
$this->approved = $approved;
return $this;
}
/**
* Get approved
*
* @return boolean
*/
public function getApproved()
{
return $this->approved;
}
/**
* Set created
*
* @param \DateTime $created
* @return Comment
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
/**
* Get created
*
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* Set updated
*
* @param \DateTime $updated
* @return Comment
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set blog
*
* @param \Blogger\BlogBundle\Entity\Blog $blog
* @return Comment
*/
public function setBlog(\Blogger\BlogBundle\Entity\Blog $blog = null)
{
$this->blog = $blog;
return $this;
}
/**
* Get blog
*
* @return \Blogger\BlogBundle\Entity\Blog
*/
public function getBlog()
{
return $this->blog;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment