src/Entity/BlogPostCategoryOrder.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlogPostCategoryOrderRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Entity\Instance;
  6. use App\Entity\SubDomain;
  7. use App\Entity\BlogPostCategory;
  8. /**
  9.  * @ORM\Entity(repositoryClass=BlogPostCategoryOrderRepository::class)
  10.  * @ORM\Table(
  11.  *     name="blog_post_category_order",
  12.  *     uniqueConstraints={
  13.  *         @ORM\UniqueConstraint(columns={"instance_id", "sub_domain_id", "category_id"})
  14.  *     }
  15.  * )
  16.  */
  17. class BlogPostCategoryOrder
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity=Instance::class)
  27.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  28.      */
  29.     private $instance;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=SubDomain::class)
  32.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  33.      */
  34.     private $subDomain;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity=BlogPostCategory::class)
  37.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  38.      */
  39.     private $category;
  40.     /**
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     private $position 0;
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getInstance(): ?Instance
  49.     {
  50.         return $this->instance;
  51.     }
  52.     public function setInstance(?Instance $instance): self
  53.     {
  54.         $this->instance $instance;
  55.         return $this;
  56.     }
  57.     public function getSubDomain(): ?SubDomain
  58.     {
  59.         return $this->subDomain;
  60.     }
  61.     public function setSubDomain(?SubDomain $subDomain): self
  62.     {
  63.         $this->subDomain $subDomain;
  64.         return $this;
  65.     }
  66.     public function getCategory(): ?BlogPostCategory
  67.     {
  68.         return $this->category;
  69.     }
  70.     public function setCategory(?BlogPostCategory $category): self
  71.     {
  72.         $this->category $category;
  73.         return $this;
  74.     }
  75.     public function getPosition(): int
  76.     {
  77.         return (int) $this->position;
  78.     }
  79.     public function setPosition(int $position): self
  80.     {
  81.         $this->position $position;
  82.         return $this;
  83.     }
  84.     public function __toString(): string
  85.     {
  86.         // Utile si tu affiches l’entité dans un select EasyAdmin
  87.         $parts = [];
  88.         if ($this->instance) {
  89.             $parts[] = (string) $this->instance;
  90.         }
  91.         if ($this->subDomain) {
  92.             $parts[] = (string) $this->subDomain;
  93.         }
  94.         if ($this->category) {
  95.             $parts[] = (string) $this->category;
  96.         }
  97.         return implode(' / '$parts) ?: 'Ordre rubrique';
  98.     }
  99. }