src/Entity/News.php line 17
<?php
namespace App\Entity;
use App\Repository\NewsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[Vich\Uploadable]
#[ORM\Entity(repositoryClass: NewsRepository::class)]
class News
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'boolean')]
private bool $active = false;
#[ORM\JoinColumn(nullable: true)]
#[ORM\ManyToOne(targetEntity: User::class)]
private ?User $author = null;
#[Assert\NotBlank]
#[ORM\Column(type: 'string', length: 255)]
private string $title;
#[Assert\NotBlank]
#[ORM\Column(type: 'text')]
private string $content;
#[ORM\Column(type: 'text')]
private string $chapo;
#[ORM\JoinColumn(nullable: true)]
#[ORM\ManyToOne(targetEntity: NewsCategory::class)]
private NewsCategory $category;
#[ORM\Column(type: 'datetime')]
private ?\DateTime $createdAt;
#[ORM\JoinTable(name: 'news_keywords')]
#[ORM\ManyToMany(targetEntity: \App\Entity\Keywords::class, inversedBy: 'mentionsNews', cascade: ['persist'])]
#[ORM\OrderBy(['keyword' => 'ASC'])]
private $listekeywords;
#[ORM\JoinTable(name: 'news_lexiques')]
#[ORM\ManyToMany(targetEntity: \App\Entity\Lexique::class, inversedBy: 'mentionsNews', cascade: ['persist'])]
#[ORM\OrderBy(['word' => 'ASC'])]
private $listelexique;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $pdf = null;
#[Vich\UploadableField(mapping: 'news_pdf', fileNameProperty:'pdf')]
private ?File $pdfFile = null;
#[ORM\Column(type: 'boolean')]
private bool $pinned = false;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
$this->listekeywords = new ArrayCollection();
$this->listelexique = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCategory(): ?NewsCategory
{
return $this->category;
}
public function setCategory(NewsCategory $category): void
{
$this->category = $category;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): void
{
$this->active = $active;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): void
{
$this->author = $author;
}
public function getListekeywords(): Collection
{
return $this->listekeywords;
}
public function getListelexique(): Collection
{
return $this->listelexique;
}
public function addListelexique(Lexique $lexique): self
{
if (!$this->listelexique->contains($lexique)) {
$this->listelexique[] = $lexique;
}
return $this;
}
public function removeListelexique(Lexique $lexique): self
{
$this->listelexique->removeElement($lexique);
return $this;
}
public function setPdfFile($pdf = null)
{
$this->pdfFile = $pdf;
// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($pdf) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}
public function getPdfFile()
{
return $this->pdfFile;
}
public function setPdf($pdf)
{
// $pdf = str_replace(' ', '_', $pdf);
$this->pdf = $pdf;
}
public function getPdf()
{
return $this->pdf;
}
public function addListekeyword(Keywords $listekeyword): self
{
if (!$this->listekeywords->contains($listekeyword)) {
$this->listekeywords[] = $listekeyword;
}
return $this;
}
public function removeListekeyword(Keywords $listekeyword): self
{
$this->listekeywords->removeElement($listekeyword);
return $this;
}
public function getChapo(): ?string
{
return $this->chapo;
}
public function setChapo(string $chapo): self
{
$this->chapo = $chapo;
return $this;
}
public function getPinned()
{
return $this->pinned;
}
public function setPinned($pinned)
{
$this->pinned = $pinned;
return $this;
}
}