| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Booking;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\Entity\Access\Access;
- use App\Entity\Core\Categories;
- use App\Entity\Core\File;
- use App\Entity\Core\Tagg;
- use App\Entity\Organization\Organization;
- use App\Entity\Place\Place;
- use App\Entity\Place\PlaceSystem;
- use App\Entity\Place\Room;
- use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table Event, et supprimer l'attribut discr.
- * @todo : migration table tag_booking
- */
- #[Auditable]
- #[ORM\Entity]
- #[ORM\Table(name: 'Booking')]
- #[ApiResource(
- collectionOperations:[],
- itemOperations: [
- "get" => ["security" => "is_granted('ROLE_ADMIN') and object.getOrganization().getId() == user.getOrganization().getId()"]
- ]
- )]
- class Event extends AbstractBooking
- {
- #[ORM\Column(length: 255, nullable: false)]
- private string $discr = 'event';
- #[ORM\ManyToOne(inversedBy: 'events')]
- #[ORM\JoinColumn(nullable: false)]
- protected Organization $organization;
- #[ORM\ManyToOne(inversedBy: 'events')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- protected Place $place;
- #[ORM\ManyToOne(inversedBy: 'events')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- protected Room $room;
- #[ORM\OneToMany(mappedBy: 'event', targetEntity: EventRecur::class, cascade: ['persist'], orphanRemoval: true)]
- private Collection $eventRecur;
- #[ORM\OneToMany(mappedBy: 'parent', targetEntity: Event::class, orphanRemoval: true)]
- private Collection $timeline;
- #[ORM\ManyToOne(inversedBy: 'timeline')]
- private Event $parent;
- #[Assert\Valid]
- #[ORM\ManyToOne(cascade: ['persist'],inversedBy: 'events')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- private File $image;
- #[ORM\ManyToOne]
- private EventGender $gender;
- #[Assert\Valid]
- #[ORM\OneToMany(mappedBy: 'event', targetEntity: EventUser::class, cascade: ['persist'], orphanRemoval: true)]
- private Collection $eventUser;
- #[ORM\ManyToMany(targetEntity: Categories::class, cascade: ['persist'])]
- private Collection $categories;
- #[ORM\OneToMany(mappedBy: 'event', targetEntity: EventReport::class, orphanRemoval: true)]
- private Collection $eventReports;
- #[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist'], orphanRemoval: true)]
- #[ORM\JoinTable(name: 'event_files')]
- #[ORM\JoinColumn(name: 'event_id', referencedColumnName: 'id', onDelete: 'cascade')]
- #[ORM\InverseJoinColumn(name: 'file_id', referencedColumnName: 'id', onDelete: 'cascade')]
- private Collection $files;
- #[ORM\ManyToOne]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- private PlaceSystem $placeSystem;
- #[ORM\OneToMany(mappedBy: 'event', targetEntity: AttendanceBooking::class, cascade: ['persist'], orphanRemoval: true)]
- #[ORM\JoinColumn(nullable: false)]
- private Collection $attendanceBooking;
- #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'eventOrganizers')]
- #[ORM\JoinTable(name: 'booking_organizer')]
- #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
- #[ORM\InverseJoinColumn(name: 'organizer_id', referencedColumnName: 'id')]
- private Collection $organizer;
- #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'events', cascade: ['persist'],)]
- #[ORM\JoinTable(name: 'tag_booking')]
- #[ORM\JoinColumn(name: 'booking_id', referencedColumnName: 'id')]
- #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- private Collection $tags;
- public function __construct()
- {
- $this->eventRecur = new ArrayCollection();
- $this->timeline = new ArrayCollection();
- $this->eventUser = new ArrayCollection();
- $this->categories = new ArrayCollection();
- $this->eventReports = new ArrayCollection();
- $this->files = new ArrayCollection();
- $this->attendanceBooking = new ArrayCollection();
- $this->organizer = new ArrayCollection();
- $this->tags = new ArrayCollection();
- }
- public function getDiscr(): ?string
- {
- return $this->discr;
- }
- public function setDiscr(string $discr): self
- {
- $this->discr = $discr;
- return $this;
- }
- public function getOrganization(): ?Organization
- {
- return $this->organization;
- }
- public function setOrganization(?Organization $organization): self
- {
- $this->organization = $organization;
- return $this;
- }
- public function getPlace(): ?Place
- {
- return $this->place;
- }
- public function setPlace(?Place $place): self
- {
- $this->place = $place;
- return $this;
- }
- public function getRoom(): ?Room
- {
- return $this->room;
- }
- public function setRoom(?Room $room): self
- {
- $this->room = $room;
- return $this;
- }
- /**
- * @return Collection<int, EventRecur>
- */
- public function getEventRecur(): Collection
- {
- return $this->eventRecur;
- }
- public function addEventRecur(EventRecur $eventRecur): self
- {
- if (!$this->eventRecur->contains($eventRecur)) {
- $this->eventRecur[] = $eventRecur;
- $eventRecur->setEvent($this);
- }
- return $this;
- }
- public function removeEventRecur(EventRecur $eventRecur): self
- {
- if ($this->eventRecur->removeElement($eventRecur)) {
- // set the owning side to null (unless already changed)
- if ($eventRecur->getEvent() === $this) {
- $eventRecur->setEvent(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Event>
- */
- public function getTimeline(): Collection
- {
- return $this->timeline;
- }
- public function addTimeline(Event $timeline): self
- {
- if (!$this->timeline->contains($timeline)) {
- $this->timeline[] = $timeline;
- $timeline->setParent($this);
- }
- return $this;
- }
- public function removeTimeline(Event $timeline): self
- {
- if ($this->timeline->removeElement($timeline)) {
- // set the owning side to null (unless already changed)
- if ($timeline->getParent() === $this) {
- $timeline->setParent(null);
- }
- }
- return $this;
- }
- public function getParent(): ?self
- {
- return $this->parent;
- }
- public function setParent(?self $parent): self
- {
- $this->parent = $parent;
- return $this;
- }
- public function getImage(): ?File
- {
- return $this->image;
- }
- public function setImage(?File $image): self
- {
- $this->image = $image;
- return $this;
- }
- public function getGender(): ?EventGender
- {
- return $this->gender;
- }
- public function setGender(?EventGender $gender): self
- {
- $this->gender = $gender;
- return $this;
- }
- /**
- * @return Collection<int, EventUser>
- */
- public function getEventUser(): Collection
- {
- return $this->eventUser;
- }
- public function addEventUser(EventUser $eventUser): self
- {
- if (!$this->eventUser->contains($eventUser)) {
- $this->eventUser[] = $eventUser;
- $eventUser->setEvent($this);
- }
- return $this;
- }
- public function removeEventUser(EventUser $eventUser): self
- {
- if ($this->eventUser->removeElement($eventUser)) {
- // set the owning side to null (unless already changed)
- if ($eventUser->getEvent() === $this) {
- $eventUser->setEvent(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Categories>
- */
- public function getCategories(): Collection
- {
- return $this->categories;
- }
- public function addCategory(Categories $category): self
- {
- if (!$this->categories->contains($category)) {
- $this->categories[] = $category;
- }
- return $this;
- }
- public function removeCategory(Categories $category): self
- {
- $this->categories->removeElement($category);
- return $this;
- }
- /**
- * @return Collection<int, EventReport>
- */
- public function getEventReports(): Collection
- {
- return $this->eventReports;
- }
- public function addEventReport(EventReport $eventReport): self
- {
- if (!$this->eventReports->contains($eventReport)) {
- $this->eventReports[] = $eventReport;
- $eventReport->setEvent($this);
- }
- return $this;
- }
- public function removeEventReport(EventReport $eventReport): self
- {
- if ($this->eventReports->removeElement($eventReport)) {
- // set the owning side to null (unless already changed)
- if ($eventReport->getEvent() === $this) {
- $eventReport->setEvent(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, File>
- */
- public function getFiles(): Collection
- {
- return $this->files;
- }
- public function addFile(File $file): self
- {
- if (!$this->files->contains($file)) {
- $this->files[] = $file;
- }
- return $this;
- }
- public function removeFile(File $file): self
- {
- $this->files->removeElement($file);
- return $this;
- }
- public function getPlaceSystem(): ?PlaceSystem
- {
- return $this->placeSystem;
- }
- public function setPlaceSystem(?PlaceSystem $placeSystem): self
- {
- $this->placeSystem = $placeSystem;
- return $this;
- }
- /**
- * @return Collection<int, AttendanceBooking>
- */
- public function getAttendanceBooking(): Collection
- {
- return $this->attendanceBooking;
- }
- public function addAttendanceBooking(AttendanceBooking $attendanceBooking): self
- {
- if (!$this->attendanceBooking->contains($attendanceBooking)) {
- $this->attendanceBooking[] = $attendanceBooking;
- $attendanceBooking->setEvent($this);
- }
- return $this;
- }
- public function removeAttendanceBooking(AttendanceBooking $attendanceBooking): self
- {
- if ($this->attendanceBooking->removeElement($attendanceBooking)) {
- // set the owning side to null (unless already changed)
- if ($attendanceBooking->getEvent() === $this) {
- $attendanceBooking->setEvent(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Access>
- */
- public function getOrganizer(): Collection
- {
- return $this->organizer;
- }
- public function addOrganizer(Access $organizer): self
- {
- if (!$this->organizer->contains($organizer)) {
- $this->organizer[] = $organizer;
- }
- return $this;
- }
- public function removeOrganizer(Access $organizer): self
- {
- $this->organizer->removeElement($organizer);
- return $this;
- }
- /**
- * @return Collection<int, Tagg>
- */
- public function getTags(): Collection
- {
- return $this->tags;
- }
- public function addTag(Tagg $tag): self
- {
- if (!$this->tags->contains($tag)) {
- $this->tags[] = $tag;
- }
- return $this;
- }
- public function removeTag(Tagg $tag): self
- {
- $this->tags->removeElement($tag);
- return $this;
- }
- }
|