TemplateSystem.php 1.9 KB

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