<?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 Notaris\AdminBundle\ValueObject\BrochureType;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="BrochureRepository")
* @ORM\Table(name="brochure")
*/
class Brochure {
/**
* @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="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="text", name="description")
*/
private $description;
/**
* @ORM\OneToOne(targetEntity="Asset", cascade={"remove"})
* @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
*/
protected $asset;
/**
* @var integer
*
* @ORM\Column(type="integer", name="pages", nullable=true)
*/
private $pages;
/**
* @ORM\Column(name="edition", type="date", nullable=true)
*/
private $edition;
/**
* @var integer
*
* @ORM\Column(type="integer", name="count_clicked")
*/
private $countClicked = 0;
/**
* @var string
*
* @ORM\Column(name="publisher", type="string", length=255)
*/
private $publisher;
/**
* @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="general_position", nullable=true)
*/
private $generalPosition;
/**
* @ORM\Column(type="boolean", name="is_general_primary")
* @Assert\Type("boolean")
*/
private $isGeneralPrimary;
/**
* @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\Subsite")
* @ORM\JoinColumn(name="primary_subsite", referencedColumnName="id", onDelete="SET NULL")
*/
private $primarySubsite;
/**
* @ORM\OneToOne(targetEntity="News", inversedBy="brochure", cascade={"remove"})
* @ORM\JoinColumn(name="news_id", referencedColumnName="id", onDelete="SET NULL")
*/
protected $news;
/**
* @ORM\ManyToMany(targetEntity="Tag", inversedBy="brochures")
* @ORM\JoinTable(name="tag_brochure")
*/
protected $tags;
/**
* @ORM\OneToMany(targetEntity="BrochureSubsite", mappedBy="brochure")
* @ORM\JoinColumn(name="id", referencedColumnName="brochure")
* @ORM\OrderBy({"position" = "asc"})
*/
private $subsites;
/**
* @ORM\ManyToMany(targetEntity="IzimiCategory")
* @ORM\JoinTable(name="brochure_izimi_category")
*/
protected $categories;
/**
* @ORM\Column(type="boolean", name="is_izimi")
* @Assert\Type("boolean")
*/
private $isIzimi;
/**
* @var BrochureType
*
* @ORM\Column(type="brochure_type", options={"default": "Brochure"})
*/
private $brochureType;
/**
* Constructor
*/
public function __construct()
{
$this->tags = new \Doctrine\Common\Collections\ArrayCollection();
$this->brochureType = BrochureType::brochure();
}
/**
* @return string
*/
public function getRelatedTo()
{
if ($this->getSubsites()) {
$default_general = 'General';
$count = count($this->getSubsites());
if (!$count && $this->getIsGeneral()) {
return $default_general;
} elseif ($count >= 1) {
if ($this->getPrimarySubsite()) {
return $this->getPrimarySubsite();
} elseif ($this->getIsGeneralPrimary()) {
return $default_general;
} else {
$subsites = $this->getSubsites();
return $subsites[0]->getSubsite();
}
}
}
return '';
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set created
*
* @param \DateTime $created
* @return Brochure
*/
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 Brochure
*/
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 Brochure
*/
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 Brochure
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description
*
* @param string $description
* @return Brochure
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set pages
*
* @param integer $pages
* @return Brochure
*/
public function setPages($pages)
{
$this->pages = $pages;
return $this;
}
/**
* Get pages
*
* @return integer
*/
public function getPages()
{
return $this->pages;
}
/**
* Set edition
*
* @param \DateTime $edition
* @return Brochure
*/
public function setEdition($edition)
{
$this->edition = $edition;
return $this;
}
/**
* Get edition
*
* @return \DateTime
*/
public function getEdition()
{
return $this->edition;
}
/**
* Set publisher
*
* @param string $publisher
* @return Brochure
*/
public function setPublisher($publisher)
{
$this->publisher = $publisher;
return $this;
}
/**
* Get publisher
*
* @return string
*/
public function getPublisher()
{
return $this->publisher;
}
/**
* Set isActive
*
* @param boolean $isActive
* @return Brochure
*/
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 Brochure
*/
public function setPublicationDate($publicationDate)
{
$this->publicationDate = $publicationDate;
return $this;
}
/**
* Get publicationDate
*
* @return \DateTime
*/
public function getPublicationDate()
{
return $this->publicationDate;
}
/**
* Set isGeneral
*
* @param boolean $isGeneral
* @return Brochure
*/
public function setIsGeneral($isGeneral)
{
$this->isGeneral = $isGeneral;
return $this;
}
/**
* Get isGeneral
*
* @return boolean
*/
public function getIsGeneral()
{
return $this->isGeneral;
}
/**
* Set user
*
* @param \Notaris\AdminBundle\Entity\User $user
* @return Brochure
*/
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 primarySubsite
*
* @param \Notaris\AdminBundle\Entity\Subsite $primarySubsite
* @return Brochure
*/
public function setPrimarySubsite(\Notaris\AdminBundle\Entity\Subsite $primarySubsite = null)
{
$this->primarySubsite = $primarySubsite;
return $this;
}
/**
* Get primarySubsite
*
* @return \Notaris\AdminBundle\Entity\Subsite
*/
public function getPrimarySubsite()
{
return $this->primarySubsite;
}
/**
* Set news
*
* @param \Notaris\AdminBundle\Entity\News $news
* @return Brochure
*/
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;
}
/**
* Add tags
*
* @param \Notaris\AdminBundle\Entity\Tag $tags
* @return Brochure
*/
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;
}
/**
* Add subsites
*
* @param \Notaris\AdminBundle\Entity\BrochureSubsite $subsites
* @return Brochure
*/
public function addSubsite(\Notaris\AdminBundle\Entity\BrochureSubsite $subsites)
{
$this->subsites[] = $subsites;
return $this;
}
/**
* Remove subsites
*
* @param \Notaris\AdminBundle\Entity\BrochureSubsite $subsites
*/
public function removeSubsite(\Notaris\AdminBundle\Entity\BrochureSubsite $subsites)
{
$this->subsites->removeElement($subsites);
}
/**
* Get subsites
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSubsites()
{
return $this->subsites;
}
/**
* Set asset
*
* @param \Notaris\AdminBundle\Entity\Asset $asset
* @return Brochure
*/
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;
}
/**
* Set isGeneralPrimary
*
* @param boolean $isGeneralPrimary
* @return Brochure
*/
public function setIsGeneralPrimary($isGeneralPrimary)
{
$this->isGeneralPrimary = $isGeneralPrimary;
return $this;
}
/**
* Get isGeneralPrimary
*
* @return boolean
*/
public function getIsGeneralPrimary()
{
return $this->isGeneralPrimary;
}
/**
* Set countClicked
*
* @param integer $countClicked
* @return Brochure
*/
public function setCountClicked($countClicked)
{
$this->countClicked = $countClicked;
return $this;
}
/**
* Get countClicked
*
* @return integer
*/
public function getCountClicked()
{
return $this->countClicked;
}
/**
* Set generalPosition
*
* @param integer $generalPosition
* @return Brochure
*/
public function setGeneralPosition($generalPosition)
{
$this->generalPosition = $generalPosition;
return $this;
}
/**
* @param BrochureType $brochureType
*/
public function setBrochureType($brochureType)
{
$this->brochureType = $brochureType;
}
/**
* Get generalPosition
*
* @return integer
*/
public function getGeneralPosition()
{
return $this->generalPosition;
}
/**
* @return BrochureType
*/
public function getBrochureType()
{
return $this->brochureType;
}
/**
* Add category
*
* @param \Notaris\AdminBundle\Entity\IzimiCategory $category
*
* @return Brochure
*/
public function addCategory(\Notaris\AdminBundle\Entity\IzimiCategory $category)
{
$this->categories[] = $category;
return $this;
}
/**
* Remove category
*
* @param \Notaris\AdminBundle\Entity\IzimiCategory $category
*/
public function removeCategory(\Notaris\AdminBundle\Entity\IzimiCategory $category)
{
$this->categories->removeElement($category);
}
/**
* Get categories
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCategories()
{
return $this->categories;
}
/**
* Set isIzimi
*
* @param boolean $isIzimi
* @return Brochure
*/
public function setIsIzimi(bool $isIzimi)
{
$this->isIzimi = $isIzimi;
return $this;
}
/**
* Get isIzimi
*
* @return boolean
*/
public function getIsIzimi()
{
return $this->isIzimi;
}
}