<?php
namespace Uniski\CMSBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass="Uniski\CMSBundle\Repository\PostRepository")
* @ORM\Table("post")
*/
class Post
{
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var Uniski\ResourceBundle\Entity\Image
* @ORM\ManyToOne(targetEntity="Uniski\ResourceBundle\Entity\Image", cascade={"persist"})
* @ORM\JoinColumn(name="image_id", referencedColumnName="id", nullable=true)
*/
protected $image;
/**
* @var string
* @ORM\Column(name="title", type="string")
*/
protected $title;
/**
* @var string
* @ORM\Column(name="body", type="text")
*/
protected $body;
/**
* @Gedmo\Slug(fields={"title"})
* @ORM\Column(length=128, unique=true)
*/
private $slug;
/**
* @var array
* @ORM\Column(name="seo", type="json")
*/
protected $seo;
/**
* @var boolean
* @ORM\Column(name="stick", type="boolean")
*/
protected $stick;
/**
* @var \Doctrine\Common\Collections\ArrayCollection
* @ORM\ManyToMany(targetEntity="\Uniski\ConfigBundle\Entity\Category", cascade={"persist","merge"})
* @ORM\JoinTable(name="post_tags",
* joinColumns={@ORM\JoinColumn(name="post_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")})
*/
protected $tags;
/**
* @var \DateTime $created
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="datetime")
*/
protected $created;
/**
* @var \DateTime $updated
*
* @Gedmo\Timestampable
* @ORM\Column(type="datetime")
*/
protected $updated;
/**
* 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 slug
*
* @param string $slug
*
* @return Post
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set seo
*
* @param array $seo
*
* @return Post
*/
public function setSeo($seo)
{
$this->seo = $seo;
return $this;
}
/**
* Get seo
*
* @return array
*/
public function getSeo()
{
return $this->seo;
}
/**
* Set image
*
* @param \Uniski\ResourceBundle\Entity\Image $image
*
* @return Post
*/
public function setImage(\Uniski\ResourceBundle\Entity\Image $image)
{
$this->image = $image;
return $this;
}
/**
* Get image
*
* @return \Uniski\ResourceBundle\Entity\Image
*/
public function getImage()
{
return $this->image;
}
/**
* Set stick
*
* @param boolean $stick
*
* @return Post
*/
public function setStick($stick)
{
$this->stick = $stick;
return $this;
}
/**
* Get stick
*
* @return boolean
*/
public function getStick()
{
return $this->stick;
}
/**
* Constructor
*/
public function __construct()
{
$this->tags = new \Doctrine\Common\Collections\ArrayCollection();
$this->created = new \DateTime();
$this->stick = false;
}
/**
* Add tag
*
* @param \Uniski\ConfigBundle\Entity\Category $tag
*
* @return Post
*/
public function addTag(\Uniski\ConfigBundle\Entity\Category $tag)
{
$this->tags[] = $tag;
return $this;
}
/**
* Remove tag
*
* @param \Uniski\ConfigBundle\Entity\Category $tag
*/
public function removeTag(\Uniski\ConfigBundle\Entity\Category $tag)
{
$this->tags->removeElement($tag);
}
/**
* Get tags
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTags()
{
return $this->tags;
}
/**
* Gets the value of updated.
*
* @return \DateTime $updated
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Sets the value of updated.
*
* @param \DateTime $updated $updated the updated
*
* @return self
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Gets the value of created.
*
* @return \DateTime $created
*/
public function getCreated()
{
return $this->created;
}
/**
* Sets the value of created.
*
* @param \DateTime $created $created the created
*
* @return self
*/
public function setCreated($created)
{
$this->created = $created;
return $this;
}
}