src/Entity/Document/BlockCategory.php line 12

  1. <?php
  2. namespace App\Entity\Document;
  3. use App\Entity\User;
  4. use App\Repository\Document\BlockCategoryRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassBlockCategoryRepository::class)]
  9. class BlockCategory
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $title null;
  17.     #[ORM\ManyToOne(inversedBy'blockCategories')]
  18.     private ?User $owner null;
  19.     #[ORM\OneToMany(mappedBy'category'targetEntityBlock::class)]
  20.     private Collection $blocks;
  21.     public function __construct()
  22.     {
  23.         $this->blocks = new ArrayCollection();
  24.     }
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getTitle(): ?string
  30.     {
  31.         return $this->title;
  32.     }
  33.     public function setTitle(string $title): static
  34.     {
  35.         $this->title $title;
  36.         return $this;
  37.     }
  38.     public function getOwner(): ?User
  39.     {
  40.         return $this->owner;
  41.     }
  42.     public function setOwner(?User $owner): static
  43.     {
  44.         $this->owner $owner;
  45.         return $this;
  46.     }
  47.     /**
  48.      * @return Collection<int, Block>
  49.      */
  50.     public function getBlocks(): Collection
  51.     {
  52.         return $this->blocks;
  53.     }
  54.     public function addBlock(Block $block): static
  55.     {
  56.         if (!$this->blocks->contains($block)) {
  57.             $this->blocks->add($block);
  58.             $block->setCategory($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeBlock(Block $block): static
  63.     {
  64.         if ($this->blocks->removeElement($block)) {
  65.             // set the owning side to null (unless already changed)
  66.             if ($block->getCategory() === $this) {
  67.                 $block->setCategory(null);
  68.             }
  69.         }
  70.         return $this;
  71.     }
  72. }