<?php
/**
* Created by PhpStorm.
* User: lisavandaele
* Date: 30/01/15
* Time: 12:53
*/
namespace Notaris\AdminBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="FaqRepository")
* @ORM\Table(name="faq")
*/
class Faq {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $user;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created", type="datetime")
*/
private $created;
/**
* @ORM\Column(name="updated", type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updated;
/**
* @var string
*
* @ORM\Column(name="locale", type="string", length=5)
*/
private $locale;
/**
* @var string
*
* @ORM\Column(name="title", type="text")
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="subtitle", type="text")
*/
private $subtitle;
/**
* @ORM\Column(type="text", name="answer")
*/
private $answer;
/**
* @ORM\OneToOne(targetEntity="Asset", cascade={"remove"})
* @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
*/
protected $asset;
/**
* @ORM\Column(type="boolean", name="is_active")
* @Assert\Type("boolean")
*/
private $isActive;
/**
* @ORM\Column(name="pub_date", type="datetime")
*/
private $publicationDate;
/**
* @ORM\Column(type="boolean", name="is_general")
* @Assert\Type("boolean")
*/
private $isGeneral;
/**
* @var integer
*
* @ORM\Column(type="integer", name="count_clicked")
*/
private $countClicked = 0;
/**
* @ORM\OneToOne(targetEntity="News", inversedBy="faq", cascade={"remove"})
* @ORM\JoinColumn(name="news_id", referencedColumnName="id", onDelete="SET NULL")
*/
protected $news;
/**
* @ORM\ManyToMany(targetEntity="Tag", inversedBy="faqItems")
* @ORM\JoinTable(name="tag_faq")
*/
protected $tags;
/**
* @Gedmo\Slug(fields={"title"})
* @ORM\Column(length=128, unique=true)
*/
private $slug;
/**
* @ORM\OneToOne(targetEntity="Meta", cascade={"remove"})
* @ORM\JoinColumn(name="meta_id", referencedColumnName="id")
*/
protected $meta;
/**
* @ORM\OneToMany(targetEntity="FaqSubsite", mappedBy="faq")
* @ORM\OrderBy({"position" = "asc"})
*/
private $subsites;
/**
* @ORM\Column(type="boolean", name="show_in_subsite", options={"default":1})
* @Assert\Type("boolean")
*/
private $showInSubsite;
/**
* Constructor
*/
public function __construct()
{
$this->attachments = new \Doctrine\Common\Collections\ArrayCollection();
$this->links = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* @return int|string
*/
public function getRelatedTo(){
if($this->getSubsites()){
$count = count($this->getSubsites());
if($count){
$subsites = $this->getSubsites();
$result = array();
foreach($subsites as $subsite){
$result[] = $subsite->getSubsite();
}
return implode('<br/>', $result);
}
else{
return $count;
}
}
return '';
}
/**
* @return string
*/
public function getRenderStatus()
{
if ($this->getIsActive()) {
$now = new \DateTime('now');
$date = $this->getPublicationDate();
if ($date <= $now) {
return '<span class="label label-success">ON</span>';
}
return '<span class="label label-warning">...</span>';
}
return '<span class="label label-danger">OFF</span>';
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set created
*
* @param \DateTime $created
* @return Faq
*/
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 Faq
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set locale
*
* @param string $locale
* @return Faq
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* Get locale
*
* @return string
*/
public function getLocale()
{
return $this->locale;
}
/**
* Set title
*
* @param string $title
* @return Faq
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set subtitle
*
* @param string $subtitle
* @return Faq
*/
public function setSubtitle($subtitle)
{
$this->subtitle = $subtitle;
return $this;
}
/**
* Get subtitle
*
* @return string
*/
public function getSubtitle()
{
return $this->subtitle;
}
/**
* Set answer
*
* @param string $answer
* @return Faq
*/
public function setAnswer($answer)
{
$this->answer = $answer;
return $this;
}
/**
* Get answer
*
* @return string
*/
public function getAnswer()
{
return $this->answer;
}
/**
* Set isActive
*
* @param boolean $isActive
* @return Faq
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set publicationDate
*
* @param \DateTime $publicationDate
* @return Faq
*/
public function setPublicationDate($publicationDate)
{
$this->publicationDate = $publicationDate;
return $this;
}
/**
* Get publicationDate
*
* @return \DateTime
*/
public function getPublicationDate()
{
return $this->publicationDate;
}
/**
* Set slug
*
* @param string $slug
* @return Faq
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set user
*
* @param \Notaris\AdminBundle\Entity\User $user
* @return Faq
*/
public function setUser(\Notaris\AdminBundle\Entity\User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \Notaris\AdminBundle\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
* Set news
*
* @param \Notaris\AdminBundle\Entity\News $news
* @return Faq
*/
public function setNews(\Notaris\AdminBundle\Entity\News $news = null)
{
$this->news = $news;
return $this;
}
/**
* Get news
*
* @return \Notaris\AdminBundle\Entity\News
*/
public function getNews()
{
return $this->news;
}
/**
* Set meta
*
* @param \Notaris\AdminBundle\Entity\Meta $meta
* @return Faq
*/
public function setMeta(\Notaris\AdminBundle\Entity\Meta $meta = null)
{
$this->meta = $meta;
return $this;
}
/**
* Get meta
*
* @return \Notaris\AdminBundle\Entity\Meta
*/
public function getMeta()
{
return $this->meta;
}
/**
* Add tags
*
* @param \Notaris\AdminBundle\Entity\Tag $tags
* @return Faq
*/
public function addTag(\Notaris\AdminBundle\Entity\Tag $tags)
{
$this->tags[] = $tags;
return $this;
}
/**
* Remove tags
*
* @param \Notaris\AdminBundle\Entity\Tag $tags
*/
public function removeTag(\Notaris\AdminBundle\Entity\Tag $tags)
{
$this->tags->removeElement($tags);
}
/**
* Get tags
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTags()
{
return $this->tags;
}
/**
* Set asset
*
* @param \Notaris\AdminBundle\Entity\Asset $asset
* @return Faq
*/
public function setAsset(\Notaris\AdminBundle\Entity\Asset $asset = null)
{
$this->asset = $asset;
return $this;
}
/**
* Get asset
*
* @return \Notaris\AdminBundle\Entity\Asset
*/
public function getAsset()
{
return $this->asset;
}
/**
* Add subsites
*
* @param \Notaris\AdminBundle\Entity\FaqSubsite $subsites
* @return Faq
*/
public function addSubsite(\Notaris\AdminBundle\Entity\FaqSubsite $subsites)
{
$this->subsites[] = $subsites;
return $this;
}
/**
* Remove subsites
*
* @param \Notaris\AdminBundle\Entity\FaqSubsite $subsites
*/
public function removeSubsite(\Notaris\AdminBundle\Entity\FaqSubsite $subsites)
{
$this->subsites->removeElement($subsites);
}
/**
* Get subsites
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSubsites()
{
return $this->subsites;
}
/**
* Set countClicked
*
* @param integer $countClicked
* @return Faq
*/
public function setCountClicked($countClicked)
{
$this->countClicked = $countClicked;
return $this;
}
/**
* Get countClicked
*
* @return integer
*/
public function getCountClicked()
{
return $this->countClicked;
}
/**
* Set isGeneral
*
* @param boolean $isGeneral
* @return Faq
*/
public function setIsGeneral($isGeneral)
{
$this->isGeneral = $isGeneral;
return $this;
}
/**
* Get isGeneral
*
* @return boolean
*/
public function getIsGeneral()
{
return $this->isGeneral;
}
/**
* Set oldId
*
* @param integer $oldId
* @return Faq
*/
public function setOldId($oldId)
{
$this->oldId = $oldId;
return $this;
}
/**
* Get oldId
*
* @return integer
*/
public function getOldId()
{
return $this->oldId;
}
/**
* Set showInSubsite
*
* @param boolean $showInSubsite
* @return Faq
*/
public function setShowInSubsite($showInSubsite)
{
$this->showInSubsite = $showInSubsite;
return $this;
}
/**
* Get showInSubsite
*
* @return boolean
*/
public function getShowInSubsite()
{
return $this->showInSubsite;
}
}