<?php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="blog")
*/
class Blog implements BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use SoftDeletableTrait;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Language")
* @ORM\JoinColumn(name="language", referencedColumnName="id")
*/
protected $language;
/**
* @var string
*
* @ORM\Column(name="content", type="text", nullable=true)
*/
private $content;
/**
* @var string
*
* @ORM\Column(name="meta_title", type="text", nullable=true)
*/
private $metaTitle;
/**
* @var string
*
* @ORM\Column(name="meta_description", type="text", nullable=true)
*/
private $metaDescription;
/**
* @var string
*
* @ORM\Column(name="meta_keywords", type="text", nullable=true)
*/
private $metaKeywords;
/**
* @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Product")
* @Doctrine\ORM\Mapping\JoinTable(name="blog_entry_products")
*/
private $products;
/**
* @var string
*
* @ORM\Column(name="alt", type="string", length=255, nullable=true)
*/
private $alt;
/**
* @var string
*
* @ORM\Column(name="image_custom_name", type="string", length=255, nullable=true)
*/
private $imageCustomName;
/**
* @return string
*/
public function getTags()
{
return $this->tags;
}
/**
* @param string $tags
*/
public function setTags($tags)
{
$this->tags = $tags;
}
/**
* @var string
*
* @ORM\Column(name="tags", type="text", nullable=true)
*/
private $tags;
/**
* @var string
*
* @ORM\Column(name="slug", type="text", nullable=true)
*/
private $slug;
/**
* @var File $imageFile
*/
protected $imageFile;
/**
* @return mixed
*/
public function getVisible()
{
return $this->visible;
}
/**
* @param mixed $visible
*/
public function setVisible($visible)
{
$this->visible = $visible;
}
/**
* @return mixed
*/
public function getSpecial()
{
return $this->special;
}
/**
* @param mixed $special
*/
public function setSpecial($special)
{
$this->special = $special;
}
/**
* @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true)
*/
protected $visible = true;
/**
* @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true)
*/
protected $special = false;
/**
* @ORM\Column(type="string", length=255, name="image_name", nullable=true)
* @var string $imageName
*/
protected $imageName;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
try {
$fileName = md5(uniqid()).'.'.$image->guessExtension();
// Move the file to the directory where brochures are stored
$brochuresDir = getcwd().'/images/blog/';
$image->move($brochuresDir, $fileName);
// Update the 'brochure' property to store the PDF file name
// instead of its contents
$this->setImageName($fileName);
$this->updatedAt = new \DateTime('now');
} catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) {
}
}
return $this;
}
/**
* @return File
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param string $imageName
*/
public function setImageName($imageName)
{
$this->imageName = $imageName;
}
/**
* @return string
*/
public function getImageName()
{
return $this->imageName;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
*
* @return Blog
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set content
*
* @param string $content
*
* @return Blog
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* Set slug
*
* @param string $slug
*
* @return Blog
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
public function getLanguage(): ?Language
{
return $this->language;
}
public function setLanguage(?Language $language): self
{
$this->language = $language;
return $this;
}
/**
* @return Collection|Product[]
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->contains($product)) {
$this->products->removeElement($product);
}
return $this;
}
/**
* @return string
*/
public function getMetaTitle()
{
return $this->metaTitle;
}
/**
* @param string $metaTitle
*/
public function setMetaTitle($metaTitle)
{
$this->metaTitle = $metaTitle;
}
/**
* @return string
*/
public function getMetaDescription()
{
return $this->metaDescription;
}
/**
* @param string $metaDescription
*/
public function setMetaDescription($metaDescription)
{
$this->metaDescription = $metaDescription;
}
/**
* @return string
*/
public function getMetaKeywords()
{
return $this->metaKeywords;
}
/**
* @param string $metaKeywords
*/
public function setMetaKeywords($metaKeywords)
{
$this->metaKeywords = $metaKeywords;
}
/**
* @return string
*/
public function getAlt()
{
return $this->alt;
}
/**
* @param string $alt
*/
public function setAlt($alt)
{
$this->alt = $alt;
}
/**
* @return string
*/
public function getImageCustomName()
{
return $this->imageCustomName;
}
/**
* @param string $imageCustomName
*/
public function setImageCustomName($imageCustomName)
{
$this->imageCustomName = $imageCustomName;
}
}