<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\WikiRepository")
*
* @ORM\Table(
* name="wiki",
* indexes={
*
* @ORM\Index(columns={"created_at"}),
* @ORM\Index(columns={"published"})
* }
* )
*
* @ORM\InheritanceType("SINGLE_TABLE")
*
* @ORM\DiscriminatorColumn(name="type", type="string")
*
* @ORM\DiscriminatorMap({
* "maker" = "MakerWiki",
* "model" = "ModelWiki",
* "category" = "CategoryWiki",
* "france" = "FranceWiki",
* "portugal" = "PortugalWiki",
* "recruitment" = "RecruitmentWiki",
* })
*/
abstract class Wiki
{
public const TYPE_B2C = 'B2C';
public const TYPE_B2B = 'B2B';
/**
* @ORM\Id
*
* @ORM\Column(type="bigint")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Wiki")
*
* @ORM\JoinColumn(name="parent", referencedColumnName="id")
*/
protected $parent;
/**
* @ORM\Column(type="string")
*/
protected $subject;
/**
* @ORM\Column(type="text")
*/
protected $content;
/**
* @ORM\OneToMany(targetEntity="App\Entity\WikiImage", mappedBy="wiki", cascade={"persist", "remove"})
*/
protected $images;
/**
* @ORM\Column(type="string")
*/
protected $reference;
/**
* @ORM\Column(type="boolean")
*/
protected $published;
/**
* @Gedmo\Timestampable(on="create")
*
* @ORM\Column(type="datetime", name="created_at")
*/
protected $createdAt;
/**
* @Gedmo\Timestampable(on="update")
*
* @ORM\Column(type="datetime", name="updated_at")
*/
protected $updatedAt;
/**
* @ORM\Column(type="string", length=255, unique=false)
*
* @Gedmo\Slug(unique=true, fields={"reference"})
*/
protected $slug;
/**
* @ORM\Column(type="integer")
*/
protected $nbViews = 0;
/**
* @ORM\Column(type="integer")
*/
protected $nbViewsPro = 0;
/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $userType;
public function __construct()
{
$this->published = false;
}
public function getId()
{
return $this->id;
}
public function getSubject()
{
return $this->subject;
}
public function setSubject($subject): void
{
$this->subject = $subject;
}
public function getParent()
{
return $this->parent;
}
public function setParent($parent): void
{
$this->parent = $parent;
}
public function getImages()
{
return $this->images;
}
public function setImages($images): void
{
$this->images = $images;
}
public function addImage(WikiImage $image): void
{
$this->images[] = $image;
$image->setWiki($this);
}
public function getMainImage()
{
foreach ($this->images as $image) {
if ($image->isMain()) {
return $image;
}
}
return false;
}
public function getExtraImages()
{
$images = [];
foreach ($this->images as $image) {
if (!$image->isMain()) {
$images[] = $image;
}
}
return $images;
}
public function getReference()
{
return $this->reference;
}
public function setReference($reference): void
{
$this->reference = $reference;
}
public function getContent()
{
return $this->content;
}
public function setContent($content): void
{
$this->content = $content;
}
public function isPublished()
{
return $this->published;
}
public function setPublished($published): void
{
$this->published = $published;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function setCreatedAt(\DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTime $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
public function getSlug()
{
return $this->slug;
}
public function setSlug($slug): void
{
$this->slug = $slug;
}
public function getNbViews()
{
return $this->nbViews;
}
public function setNbViews($nbViews): void
{
$this->nbViews = $nbViews;
}
public function addOneToNbViews(): void
{
++$this->nbViews;
}
public function getNbViewsPro()
{
return $this->nbViewsPro;
}
public function setNbViewsPro($nbViewsPro): void
{
$this->nbViewsPro = $nbViewsPro;
}
public function addOneToNbViewsPro(): void
{
++$this->nbViewsPro;
}
public function getUserType()
{
return $this->userType;
}
public function setUserType($userType): void
{
$this->userType = $userType;
}
}