Created
April 10, 2014 01:29
-
-
Save harmstyler/10335656 to your computer and use it in GitHub Desktop.
Blog Post Doctrine Entity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Blend\Iterate\BlogBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* Post | |
* | |
* @ORM\Table() | |
* @ORM\Entity | |
* @ORM\HasLifecycleCallbacks | |
*/ | |
class Post | |
{ | |
/** | |
* @var integer | |
* | |
* @ORM\Column(name="id", type="integer") | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
private $id; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="title", type="string", length=255) | |
*/ | |
private $title; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="body", type="text") | |
*/ | |
private $body; | |
/** | |
* @var \DateTime | |
* | |
* @ORM\Column(name="created", type="datetime") | |
*/ | |
private $created; | |
/** | |
* @var \DateTime | |
* | |
* @ORM\Column(name="updated", type="datetime") | |
*/ | |
private $updated; | |
public function __construct() | |
{ | |
$this->setCreated(new \DateTime()); | |
$this->setUpdated(new \DateTime()); | |
} | |
/** | |
* Get id | |
* | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Set title | |
* | |
* @param string $title | |
* @return Post | |
*/ | |
public function setTitle($title) | |
{ | |
$this->title = $title; | |
return $this; | |
} | |
/** | |
* Get title | |
* | |
* @return string | |
*/ | |
public function getTitle() | |
{ | |
return $this->title; | |
} | |
/** | |
* Set body | |
* | |
* @param string $body | |
* @return Post | |
*/ | |
public function setBody($body) | |
{ | |
$this->body = $body; | |
return $this; | |
} | |
/** | |
* Get body | |
* | |
* @return string | |
*/ | |
public function getBody() | |
{ | |
return $this->body; | |
} | |
/** | |
* Set created | |
* | |
* @param \DateTime $created | |
* @return Post | |
*/ | |
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 Post | |
*/ | |
public function setUpdated($updated) | |
{ | |
$this->updated = $updated; | |
return $this; | |
} | |
/** | |
* Get updated | |
* | |
* @return \DateTime | |
*/ | |
public function getUpdated() | |
{ | |
return $this->updated; | |
} | |
/** | |
* Auto set the updated date | |
* | |
* @ORM\PreUpdate | |
*/ | |
public function setUpdatedValue() | |
{ | |
$this->setUpdated(new \DateTime()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment