TemplateSystem.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Message;
  4. use App\Entity\Core\File;
  5. use App\Entity\Organization\Organization;
  6. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * Classe ... qui ...
  12. */
  13. // #[Auditable]
  14. #[ORM\Entity]
  15. class TemplateSystem
  16. {
  17. #[ORM\Id]
  18. #[ORM\Column]
  19. #[ORM\GeneratedValue]
  20. private ?int $id = null;
  21. #[ORM\ManyToOne]
  22. private Organization $organization;
  23. #[ORM\OneToMany(targetEntity: File::class, mappedBy: 'templateSystem', orphanRemoval: true)]
  24. private Collection $files;
  25. public function __construct()
  26. {
  27. $this->files = new ArrayCollection();
  28. }
  29. public function getId(): ?int
  30. {
  31. return $this->id;
  32. }
  33. public function getOrganization(): ?Organization
  34. {
  35. return $this->organization;
  36. }
  37. public function setOrganization(?Organization $organization): self
  38. {
  39. $this->organization = $organization;
  40. return $this;
  41. }
  42. /**
  43. * @return Collection<int, File>
  44. */
  45. public function getFiles(): Collection
  46. {
  47. return $this->files;
  48. }
  49. public function addFile(File $file): self
  50. {
  51. if (!$this->files->contains($file)) {
  52. $this->files[] = $file;
  53. $file->setTemplateSystem($this);
  54. }
  55. return $this;
  56. }
  57. public function removeFile(File $file): self
  58. {
  59. if ($this->files->removeElement($file)) {
  60. // set the owning side to null (unless already changed)
  61. if ($file->getTemplateSystem() === $this) {
  62. $file->setTemplateSystem(null);
  63. }
  64. }
  65. return $this;
  66. }
  67. }