src/Entity/Blog/Article.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Blog;
  3. use App\Entity\Page\Page;
  4. use App\Repository\Blog\ArticleRepository;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  8. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  9. #[ORM\Entity(repositoryClassArticleRepository::class)]
  10. class Article  implements TranslatableInterface
  11. {
  12.     use TranslatableTrait;
  13.     
  14.     #[ORM\Valid]
  15.     protected $translations;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $image null;
  22.     #[ORM\OneToOne(inversedBy'article'cascade: ['persist''remove'])]
  23.     private ?Page $page null;
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getImage(): ?string
  29.     {
  30.         return $this->image;
  31.     }
  32.     public function setImage(?string $image): static
  33.     {
  34.         $this->image $image;
  35.         return $this;
  36.     }
  37.     public function getPage(): ?Page
  38.     {
  39.         return $this->page;
  40.     }
  41.     public function setPage(?Page $page): static
  42.     {
  43.         $this->page $page;
  44.         return $this;
  45.     }
  46.     public function __toString()
  47.     {
  48.         if($this->translate()->getTitre()) {
  49.             return $this->translate()->getTitre();
  50.         }
  51.         return '';
  52.     }
  53.     //On triche pour ne pas repasser sur le front et dev en cours
  54.     public function getTitre()
  55.     {
  56.         if($this->translate()->getTitre()) {
  57.             return $this->translate()->getTitre();
  58.         }
  59.         return '';
  60.     }
  61.     public function getTitreLangue($lang): ?string
  62.     {
  63.         if($this->translate($lang)->getTitre()) {
  64.             return $this->translate($lang)->getTitre();
  65.         }
  66.         return '';
  67.     }
  68.     public function getContenu()
  69.     {
  70.         if($this->translate()->getContenu()) {
  71.             return $this->translate()->getContenu();
  72.         }
  73.         return '';
  74.     }
  75.     public function getContenuLangue($lang): ?string
  76.     {
  77.         if($this->translate($lang)->getContenu()) {
  78.             return $this->translate($lang)->getContenu();
  79.         }
  80.         return '';
  81.     }
  82. }