<?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;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity(repositoryClass="SectionRepository")
* @ORM\Table(name="section")
*/
class Section {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created", type="datetime")
*/
private $created;
/**
* @ORM\Column(name="updated", type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updated;
/**
* @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $user;
/**
* @var string
*
* @ORM\Column(name="navigation", type="string", length=255)
*/
private $navigation;
/**
* @Gedmo\Slug(fields={"navigation"})
* @ORM\Column(length=128, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="boolean", name="is_active")
* @Assert\Type("boolean")
*/
private $isActive;
/**
* @ORM\Column(name="pub_date", type="datetime", nullable=true)
*/
private $publicationDate;
/**
* @ORM\Column(type="boolean", name="show_navigation", nullable=true)
* @Assert\Type("boolean")
*/
private $show_navigation;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="text", name="description", nullable=true)
*/
private $description;
/**
* @ORM\OneToOne(targetEntity="Asset")
* @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
*/
protected $asset;
/**
* @ORM\ManyToOne(targetEntity="Notaris\AdminBundle\Entity\Subsite", inversedBy="sections")
* @ORM\JoinColumn(name="subsite_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $subsite;
/**
* @ORM\OneToMany(targetEntity="Section", mappedBy="parent")
* @ORM\OrderBy({"position" = "ASC"})
*/
private $children;
/**
* @ORM\ManyToOne(targetEntity="Section", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $parent;
/**
* @var integer
*
* @ORM\Column(type="integer")
*/
private $position = 0;
/**
* @ORM\OneToMany(targetEntity="SectionParagraph", mappedBy="section")
* @ORM\OrderBy({"position" = "asc"})
*/
protected $paragraphs;
/**
* @ORM\OneToMany(targetEntity="SectionModule", mappedBy="section")
* @ORM\OrderBy({"position" = "asc"})
*/
protected $modules;
/**
* @ORM\OneToOne(targetEntity="Meta")
* @ORM\JoinColumn(name="meta_id", referencedColumnName="id")
*/
protected $meta;
/**
* @ORM\ManyToMany(targetEntity="Tag", inversedBy="sections")
* @ORM\JoinTable(name="tag_section")
*/
protected $tags;
/**
* @ORM\Column(type="boolean", name="not_delete", nullable=true)
* @Assert\Type("boolean")
*/
protected $notDeleted;
/**
* @ORM\Column(type="text", name="redirect_url", nullable=true)
*/
protected $redirectUrl;
/**
* @return string
*/
public function getRenderStatus()
{
if ($this->getIsActive()) {
$now = new \DateTime('now');
$date = $this->getPublicationDate();
if(!($date instanceof \DateTime)){
$date = new \DateTime($date);
}
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>';
}
/**
* @return string
*/
public function getNavigationCaption()
{
return $this->getNavigation();
}
/**
* @return string
*/
public function getCount()
{
return 0;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set created
*
* @param \DateTime $created
* @return Section
*/
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 Section
*/
public function setUpdated($updated)
{
$this->updated = $updated;
return $this;
}
/**
* Get updated
*
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* Set navigation
*
* @param string $navigation
* @return Section
*/
public function setNavigation($navigation)
{
$this->navigation = $navigation;
return $this;
}
/**
* Get navigation
*
* @return string
*/
public function getNavigation()
{
return $this->navigation;
}
/**
* Set slug
*
* @param string $slug
* @return Section
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set publicationDate
*
* @param \DateTime $publicationDate
* @return Section
*/
public function setPublicationDate($publicationDate)
{
$this->publicationDate = $publicationDate;
return $this;
}
/**
* Get publicationDate
*
* @return \DateTime
*/
public function getPublicationDate()
{
return $this->publicationDate;
}
/**
* Set show_navigation
*
* @param boolean $showNavigation
* @return Section
*/
public function setShowNavigation($showNavigation)
{
$this->show_navigation = $showNavigation;
return $this;
}
/**
* Get show_navigation
*
* @return boolean
*/
public function getShowNavigation()
{
return $this->show_navigation;
}
/**
* Set title
*
* @param string $title
* @return Section
*/
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 Section
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set position
*
* @param integer $position
* @return Section
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
/**
* Get position
*
* @return integer
*/
public function getPosition()
{
return $this->position;
}
/**
* Set user
*
* @param \Notaris\AdminBundle\Entity\User $user
* @return Section
*/
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 parent
*
* @param \Notaris\AdminBundle\Entity\Section $parent
* @return Section
*/
public function setParent(\Notaris\AdminBundle\Entity\Section $parent = null)
{
$this->parent = $parent;
return $this;
}
/**
* Get parent
*
* @return \Notaris\AdminBundle\Entity\Section
*/
public function getParent()
{
return $this->parent;
}
/**
* Constructor
*/
public function __construct()
{
$this->paragraphs = new ArrayCollection();
$this->modules = new ArrayCollection();
$this->children = new ArrayCollection();
}
/**
* Add paragraphs
*
* @param \Notaris\AdminBundle\Entity\SectionParagraph $paragraphs
* @return Section
*/
public function addParagraph(\Notaris\AdminBundle\Entity\SectionParagraph $paragraphs)
{
$this->paragraphs[] = $paragraphs;
return $this;
}
/**
* Remove paragraphs
*
* @param \Notaris\AdminBundle\Entity\SectionParagraph $paragraphs
*/
public function removeParagraph(\Notaris\AdminBundle\Entity\SectionParagraph $paragraphs)
{
$this->paragraphs->removeElement($paragraphs);
}
/**
* Get paragraphs
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getParagraphs()
{
return $this->paragraphs;
}
/**
* Add modules
*
* @param \Notaris\AdminBundle\Entity\SectionModule $modules
* @return Section
*/
public function addModule(\Notaris\AdminBundle\Entity\SectionModule $modules)
{
$this->modules[] = $modules;
return $this;
}
/**
* Remove modules
*
* @param \Notaris\AdminBundle\Entity\SectionModule $modules
*/
public function removeModule(\Notaris\AdminBundle\Entity\SectionModule $modules)
{
$this->modules->removeElement($modules);
}
/**
* Get modules
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getModules()
{
return $this->modules;
}
/**
* Add tags
*
* @param \Notaris\AdminBundle\Entity\Tag $tags
* @return Section
*/
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 meta
*
* @param \Notaris\AdminBundle\Entity\Meta $meta
* @return Section
*/
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;
}
/**
* Set isActive
*
* @param boolean $isActive
* @return Section
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set asset
*
* @param \Notaris\AdminBundle\Entity\Asset $asset
* @return Section
*/
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 subsite
*
* @param \Notaris\AdminBundle\Entity\Subsite $subsite
* @return Section
*/
public function setSubsite(\Notaris\AdminBundle\Entity\Subsite $subsite = null)
{
$this->subsite = $subsite;
return $this;
}
/**
* Get subsite
*
* @return \Notaris\AdminBundle\Entity\Subsite
*/
public function getSubsite()
{
return $this->subsite;
}
/**
* Add children
*
* @param \Notaris\AdminBundle\Entity\Section $children
* @return Section
*/
public function addChild(\Notaris\AdminBundle\Entity\Section $children)
{
$this->children[] = $children;
return $this;
}
/**
* Remove children
*
* @param \Notaris\AdminBundle\Entity\Section $children
*/
public function removeChild(\Notaris\AdminBundle\Entity\Section $children)
{
$this->children->removeElement($children);
}
/**
* Get children
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getChildren()
{
return $this->children;
}
/**
* Set notDeleted
*
* @param boolean $notDeleted
* @return Section
*/
public function setNotDeleted($notDeleted)
{
$this->notDeleted = $notDeleted;
return $this;
}
/**
* Get notDeleted
*
* @return boolean
*/
public function getNotDeleted()
{
return $this->notDeleted;
}
/**
* Set redirectUrl
*
* @param string $redirectUrl
*
* @return Section
*/
public function setRedirectUrl($redirectUrl)
{
$this->redirectUrl = $redirectUrl;
return $this;
}
/**
* Get redirectUrl
*
* @return string
*/
public function getRedirectUrl()
{
return $this->redirectUrl;
}
}