<?php

namespace OfficeBrain\Bundle\BlogBundle\Entity;


use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;


/**
 * Post
 *
 * @ORM\Table("tbl_blog_post")
 * @ORM\Entity(repositoryClass="OfficeBrain\Bundle\BlogBundle\Entity\PostRepository")
 */
class Post
{
    
    
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * 
     */
    private $id;
    
    /**
     * @var string
     *
     * @ORM\Column(name="post_name", type="string", length=255)
     * @Assert\NotBlank(message="This field is required.")
     * 
     */
    private $postName;

     /**
     * @var string
     * @Gedmo\Slug(fields={"postName","id"})
     * @ORM\Column(length=128, unique=true,nullable=true)
     */
    private $slug;

    
    /**
     * @var string
     *
     * @ORM\Column(name="short_content", type="text")
     * 
     * 
     */
    private $shortContent;


    /**
     * @var string
     *
     * @ORM\Column(name="post_content", type="text")
     * @Assert\NotBlank(message="This field is required.")
     * 
     */
    private $postContent;


    /**
     * @var string
     *
     * @ORM\Column(name="meta_title", type="string", nullable=true)
     * 
     */
    private $metaTitle;

    /**
     * @var string
     *
     * @ORM\Column(name="meta_desc", type="text", nullable=true)
     * 
     */
    private $metaDesc;


    /**
     * @var string
     *
     * @ORM\Column(name="published_date", type="datetime", nullable=true)
     * @Assert\NotBlank(message="This field is required.")
     * 
     */
    private $publishedDate;


    /**
     * @var string
     *
     * @ORM\Column(name="feature_images",type="string", nullable=true)
     * @Assert\NotBlank(message="This field is required.", groups={"create"})
     * 
     */
    private $featureImage;


    /**
     * @var boolean
     *
     * @ORM\Column(name="post_status", type="string", nullable=true)
     */
    private $postStatus;

    /**
     * @var \DateTime
     * 
     * @ORM\Column(name="post_created_date", type="datetime")
     * @Gedmo\Timestampable(on="create")
     */
    private $postCreatedDate;

    /**
     * @var \DateTime
     * 
     * @ORM\Column(name="post_updated_date", type="datetime")
     * @Gedmo\Timestampable(on="update")
     */
    private $postUpdatedDate;
    
     /**
     * @var boolean
     *
     * @ORM\Column(name="post_is_deleted", type="boolean",  options={"default" = "0"})
     */
    private $postIsDeleted;
    
   /**
     * @ORM\OneToMany(targetEntity="PostCategoryInfo", mappedBy="postId")
     */
    protected $postCategoryInfo; 
    
   /**
     * @ORM\OneToMany(targetEntity="PostTagInfo", mappedBy="postId")
     */
    protected $postTagInfo; 
    
    /**
     * @ORM\OneToMany(targetEntity="Comment", mappedBy="commentPostId")
     */
    protected $comment;
   
 
    protected $postCategoryId; 
    
    
    protected $postTagId; 
    
    public function getPostCategoryId()
    {
        return $this->postCategoryId;
    }
    
    public function setPostCategoryId($postCategoryId)
    {
        $this->postCategoryId = $postCategoryId;

        return $this;
    }
    
   
    public function getPostTagId()
    {
        return $this->postTagId;
    }
    
   public function setPostTagId($postTagId)
    {
        $this->postTagId = $postTagId;

        return $this;
    }
       
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->postCategoryInfo = new \Doctrine\Common\Collections\ArrayCollection();
        $this->postTagInfo = new \Doctrine\Common\Collections\ArrayCollection();
        $this->comment = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set postName
     *
     * @param string $postName
     * @return Post
     */
    public function setPostName($postName)
    {
        $this->postName = $postName;

        return $this;
    }

    /**
     * Get postName
     *
     * @return string 
     */
    public function getPostName()
    {
        return $this->postName;
    }

    /**
     * Set postTitle
     *
     * @param string $postTitle
     * @return Post
     */
    public function setPostTitle($postTitle)
    {
        $this->postTitle = $postTitle;

        return $this;
    }

    /**
     * Get postTitle
     *
     * @return string 
     */
    public function getPostTitle()
    {
        return $this->postTitle;
    }


    /**
     * Set shortContent
     *
     * @param string $shortContent
     * @return Post
     */
    public function setShortContent($postContent)
    {
        $scontent = strip_tags($postContent);
        $scontent = substr($scontent,0,150);
        $this->shortContent = $scontent;
        return $this;
    }

    /**
     * Get shortContent
     *
     * @return string 
     */
    public function getShortContent()
    {
        return $this->shortContent;
    }


    /**
     * Set postContent
     *
     * @param string $postContent
     * @return Post
     */
    public function setPostContent($postContent)
    {
        $this->postContent = $postContent;
        $this->setShortContent($this->postContent);

        return $this;
    }

    /**
     * Get postContent
     *
     * @return string 
     */
    public function getPostContent()
    {
        return $this->postContent;
    }


    /**
     * Set metaTitle
     *
     * @param string $metaTitle
     * @return Post
     */
    public function setMetaTitle($metaTitle)
    {
        $this->metaTitle = $metaTitle;

        return $this;
    }

    /**
     * Get metaTitle
     *
     * @return string 
     */
    public function getMetaTitle()
    {
        return $this->metaTitle;
    }


    /**
     * Set metaDesc
     *
     * @param string $metaDesc
     * @return Post
     */
    public function setMetaDesc($metaDesc)
    {
        $this->metaDesc = $metaDesc;

        return $this;
    }

    /**
     * Get metaDesc
     *
     * @return string 
     */
    public function getMetaDesc()
    {
        return $this->metaDesc;
    }

    /**
     * Set publishedDate
     *
     * @param string $publishedDate
     * @return Post
     */
    public function setPublishedDate($publishedDate)
    {
        $this->publishedDate = $publishedDate;

        return $this;
    }

    /**
     * Get publishedDate
     *
     * @return string 
     */
    public function getPublishedDate()
    {
        return $this->publishedDate;
    }

    /**
     * Set featureImage
     *
     * @param string $featureImage
     * @return Post
     */
    public function setFeatureImage($featureImage)
    {
        $this->featureImage = $featureImage;

        return $this;
    }

    /**
     * Get featureImage
     *
     * @return string 
     */
    public function getFeatureImage()
    {
        return $this->featureImage;
    }


    /**
     * Set postStatus
     *
     * @param boolean $postStatus
     * @return Post
     */
    public function setPostStatus($postStatus)
    {
        $this->postStatus = $postStatus;

        return $this;
    }

    /**
     * Get postStatus
     *
     * @return boolean 
     */
    public function getPostStatus()
    {
        return $this->postStatus;
    }

    /**
     * Set postCreatedDate
     *
     * @param \DateTime $postCreatedDate
     * @return Post
     */
    public function setPostCreatedDate($postCreatedDate)
    {
        $this->postCreatedDate = $postCreatedDate;

        return $this;
    }

    /**
     * Get postCreatedDate
     *
     * @return \DateTime 
     */
    public function getPostCreatedDate()
    {
        return $this->postCreatedDate;
    }

    /**
     * Set postUpdatedDate
     *
     * @param \DateTime $postUpdatedDate
     * @return Post
     */
    public function setPostUpdatedDate($postUpdatedDate)
    {
        $this->postUpdatedDate = $postUpdatedDate;

        return $this;
    }

    /**
     * Get postUpdatedDate
     *
     * @return \DateTime 
     */
    public function getPostUpdatedDate()
    {
        return $this->postUpdatedDate;
    }

    /**
     * Set postIsDeleted
     *
     * @param boolean $postIsDeleted
     * @return Post
     */
    public function setPostIsDeleted($postIsDeleted)
    {
        $this->postIsDeleted = $postIsDeleted;

        return $this;
    }

    /**
     * Get postIsDeleted
     *
     * @return boolean 
     */
    public function getPostIsDeleted()
    {
        return $this->postIsDeleted;
    }

    /**
     * Add postCategoryInfo
     *
     * @param \OfficeBrain\Bundle\BlogBundle\Entity\PostCategoryInfo $postCategoryInfo
     * @return Post
     */
    public function addPostCategoryInfo(\OfficeBrain\Bundle\BlogBundle\Entity\PostCategoryInfo $postCategoryInfo)
    {
        $this->postCategoryInfo[] = $postCategoryInfo;

        return $this;
    }

    /**
     * Remove postCategoryInfo
     *
     * @param \OfficeBrain\Bundle\BlogBundle\Entity\PostCategoryInfo $postCategoryInfo
     */
    public function removePostCategoryInfo(\OfficeBrain\Bundle\BlogBundle\Entity\PostCategoryInfo $postCategoryInfo)
    {
        $this->postCategoryInfo->removeElement($postCategoryInfo);
    }

    /**
     * Get postCategoryInfo
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getPostCategoryInfo()
    {
        return $this->postCategoryInfo;
    }

    /**
     * Add postTagInfo
     *
     * @param \OfficeBrain\Bundle\BlogBundle\Entity\PostTagInfo $postTagInfo
     * @return Post
     */
    public function addPostTagInfo(\OfficeBrain\Bundle\BlogBundle\Entity\PostTagInfo $postTagInfo)
    {
        $this->postTagInfo[] = $postTagInfo;

        return $this;
    }

    /**
     * Remove postTagInfo
     *
     * @param \OfficeBrain\Bundle\BlogBundle\Entity\PostTagInfo $postTagInfo
     */
    public function removePostTagInfo(\OfficeBrain\Bundle\BlogBundle\Entity\PostTagInfo $postTagInfo)
    {
        $this->postTagInfo->removeElement($postTagInfo);
    }

    /**
     * Get postTagInfo
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getPostTagInfo()
    {
        return $this->postTagInfo;
    }
    
    public function getSlug() {
        return $this->slug;
    }

    public function setSlug($slug){
        $this->slug = $slug;
        return $this;
    }

    /**
     * Add comment
     *
     * @param \OfficeBrain\Bundle\BlogBundle\Entity\Comment $comment
     * @return Post
     */
    public function addComment(\OfficeBrain\Bundle\BlogBundle\Entity\Comment $comment)
    {
        $this->comment[] = $comment;

        return $this;
    }

    /**
     * Remove comment
     *
     * @param \OfficeBrain\Bundle\BlogBundle\Entity\Comment $comment
     */
    public function removeComment(\OfficeBrain\Bundle\BlogBundle\Entity\Comment $comment)
    {
        $this->comment->removeElement($comment);
    }

    /**
     * Get comment
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getComment()
    {
        return $this->comment;
    }
}
