<?php
namespace MLDev\PublicationBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use MLDev\BaseBundle\Contract\SeoSite\SeoSiteInfoInterface;
use MLDev\BaseBundle\Entity\Traits\Timestampable;
use MLDev\BaseBundle\Annotation\Uploadable;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Item
*
* @ORM\Table(name="MLDev_Publication_Item")
* @ORM\Entity(repositoryClass="MLDev\PublicationBundle\Repository\ItemRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Item
{
use Timestampable;
/**
* @var int
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @Gedmo\Slug(fields={"name"}, updatable=false, unique=true, separator="-")
* @ORM\Column(name="alias", type="string", length=255, nullable=false)
*/
private $alias;
/**
* @var string|null
*
* @ORM\Column(name="annotation", type="text", nullable=true)
*/
private $annotation;
/**
* @var string|null
*
* @ORM\Column(name="content", type="text", nullable=true)
*/
private $content;
/**
* @var string
*
* @ORM\Column(name="author", type="string", length=255, nullable=true)
*/
private $author;
/**
* @var bool
*
* @ORM\Column(name="isActive", type="boolean")
*/
private $isActive;
/**
* @var int
*
* @ORM\Column(name="priority", type="integer")
*/
private $priority = 100;
/**
* @var \DateTime
* @ORM\Column(name="date", type="datetime", nullable=true)
*/
private $date;
/**
* @ORM\Column(type="string", name="image", nullable=true)
*
* @Uploadable(directoryAlias="page")
* @Assert\File(mimeTypes={"image/jpeg", "image/jpg", "image/png"})
*/
private $image = null;
/**
* @ORM\ManyToOne(targetEntity="\MLDev\PublicationBundle\Entity\Category", inversedBy="items")
*/
private $category;
/**
* @ORM\ManyToMany(targetEntity=SeoSiteInfoInterface::class, cascade={"persist"})
* @ORM\JoinTable(
* name="MLDev_Publication_SeoInfo",
* joinColumns={
* @ORM\JoinColumn(name="publication_id", referencedColumnName="id", onDelete="CASCADE")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="seo_info_id", referencedColumnName="id", onDelete="CASCADE")
* }
* )
*/
private $seoInfo;
/**
* @var string
*
* @ORM\Column(name="link", type="text", nullable=true)
*/
private $link;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Item
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set alias.
*
* @param string $alias
*
* @return Item
*/
public function setAlias($alias)
{
$this->alias = $alias;
return $this;
}
/**
* Get alias.
*
* @return string
*/
public function getAlias()
{
return $this->alias;
}
/**
* Set annotation.
*
* @param string|null $annotation
*
* @return Item
*/
public function setAnnotation($annotation = null)
{
$this->annotation = $annotation;
return $this;
}
/**
* Get annotation.
*
* @return string|null
*/
public function getAnnotation()
{
return $this->annotation;
}
/**
* Set content.
*
* @param string|null $content
*
* @return Item
*/
public function setContent($content = null)
{
$this->content = $content;
return $this;
}
/**
* Get content.
*
* @return string|null
*/
public function getContent()
{
return $this->content;
}
public function getAuthor(): ?string
{
return $this->author;
}
public function setAuthor(?string $author): self
{
$this->author = $author;
return $this;
}
/**
* Set isActive.
*
* @param bool $isActive
*
* @return Item
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive.
*
* @return bool
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set priority.
*
* @param int $priority
*
* @return Item
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority.
*
* @return int
*/
public function getPriority()
{
return $this->priority;
}
/**
* @return \DateTime
*/
public function getDate(): ?\DateTime
{
return $this->date;
}
/**
* @param \DateTime $date
*/
public function setDate(?\DateTime $date): void
{
$this->date = $date;
}
/**
* @return null
*/
public function getImage()
{
return $this->image;
}
/**
* @param null $image
*/
public function setImage($image): void
{
$this->image = $image;
}
/**
* @ORM\PrePersist()
*/
public function onPrePersistDate()
{
if ($this->date === null) {
$this->date = new \DateTime('now');
}
}
/**
* @ORM\PreUpdate()
*/
public function onPreUpdateDate()
{
if ($this->date === null) {
$this->date = new \DateTime('now');
}
}
/**
* @return mixed
*/
public function getCategory()
{
return $this->category;
}
/**
* @param mixed $category
*/
public function setCategory($category)
{
$this->category = $category;
}
/**
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getSeoInfo()
{
return $this->seoInfo;
}
/**
* @param \Doctrine\Common\Collections\ArrayCollection $seoInfo
*/
public function setSeoInfo($seoInfo): void
{
$this->seoInfo = $seoInfo;
}
public function getLink(): ?string
{
return $this->link;
}
public function setLink(?string $link): self
{
$this->link = $link;
return $this;
}
}