<?php
namespace App\Entity\Blog;
use App\Entity\Page\Page;
use App\Repository\Blog\ArticleRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
#[ORM\Entity(repositoryClass: ArticleRepository::class)]
class Article implements TranslatableInterface
{
use TranslatableTrait;
#[ORM\Valid]
protected $translations;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image = null;
#[ORM\OneToOne(inversedBy: 'article', cascade: ['persist', 'remove'])]
private ?Page $page = null;
public function getId(): ?int
{
return $this->id;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): static
{
$this->image = $image;
return $this;
}
public function getPage(): ?Page
{
return $this->page;
}
public function setPage(?Page $page): static
{
$this->page = $page;
return $this;
}
public function __toString()
{
if($this->translate()->getTitre()) {
return $this->translate()->getTitre();
}
return '';
}
//On triche pour ne pas repasser sur le front et dev en cours
public function getTitre()
{
if($this->translate()->getTitre()) {
return $this->translate()->getTitre();
}
return '';
}
public function getTitreLangue($lang): ?string
{
if($this->translate($lang)->getTitre()) {
return $this->translate($lang)->getTitre();
}
return '';
}
public function getContenu()
{
if($this->translate()->getContenu()) {
return $this->translate()->getContenu();
}
return '';
}
public function getContenuLangue($lang): ?string
{
if($this->translate($lang)->getContenu()) {
return $this->translate($lang)->getContenu();
}
return '';
}
}