| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Core;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\Entity\Organization\Organization;
- use App\Entity\Person\Person;
- use App\Repository\Core\FileRepository;
- use DateTime;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use JetBrains\PhpStorm\Pure;
- #[ApiResource(
- collectionOperations: [],
- itemOperations: [
- 'get',
- 'put'
- ]
- )]
- #[ORM\Entity(repositoryClass: FileRepository::class)]
- class File
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- /**
- * Propriétaire du fichier
- *
- * @var Person
- */
- #[ORM\ManyToOne]
- private Person $person;
- /**
- * Organisation propriétaire du fichier
- * @var Organization
- */
- #[ORM\ManyToOne]
- private Organization $organization;
- /**
- * Slug du fichier (i.e. le chemin d'accès relatif)
- * @var string
- */
- #[ORM\Column(length: 255)]
- private string $slug;
- /**
- * Chemin d'accès du fichier
- * @var string
- */
- #[ORM\Column(length: 255)]
- private string $path;
- /**
- * Nom du fichier
- * @var string
- */
- #[ORM\Column(length: 255)]
- private string $name;
- /**
- * Mimetype du fichier
- * @var string|null
- */
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $mimeType = null;
- /**
- * Visibilité du fichier (tout le monde, personne, l'organisation seulement...)
- * @var string
- */
- #[ORM\Column(length: 24, options: ['default' => 'NOBODY'])]
- private string $visibility = 'NOBODY';
- /**
- * Configuration particulière associée au fichier (exemple: image recadrée)
- * @var string|null
- */
- #[ORM\Column(type: 'text', length: 255, nullable: true)]
- private ?string $config;
- /**
- * Dossier contenant le fichier
- * @var string
- */
- #[ORM\Column(length: 24)]
- private string $folder;
- /**
- * Type de document (uploaded, mail, bill...etc)
- * @var string
- */
- #[ORM\Column(length: 50, options: ['default' => 'NONE'])]
- private string $type = "NONE";
- /**
- * Taille du document en octets
- * @var int|null
- */
- #[ORM\Column]
- private ?int $size;
- /**
- * Un fichier est temporaire par exemple s'il a été généré et est stocké pour être téléchargé dans la foulée
- * Les fichiers temporaires peuvent être supprimés sans risque, à l'inverse des fichiers uploadés par les
- * utilisateurs par exemple.
- *
- * @var boolean
- */
- #[ORM\Column(options: ['default' => false])]
- private bool $isTemporaryFile = false;
- /**
- * Date de création du fichier
- * @var DateTime
- */
- #[ORM\Column]
- private DateTime $createDate;
- /**
- * Id de l'access ayant créé ce fichier
- * @var int|null
- */
- #[ORM\Column]
- private ?int $createdBy;
- /**
- * Date de dernière mise à jour du fichier
- * @var DateTime
- */
- #[ORM\Column]
- private DateTime $updateDate;
- /**
- * Id de l'access ayant mis à jour ce fichier le dernier
- * @var int|null
- */
- #[ORM\Column]
- private ?int $updatedBy;
- // #[ORM\Column]
- // private ?int $eventReport_id;
- //
- // #[ORM\Column]
- // private ?\DateTime $availabilityDate;
- //
- // #[ORM\Column]
- // private ?int $documentWish_id;
- //
- // #[ORM\Column]
- // private ?int $onlineRegistrationSetting_id;
- //
- // #[ORM\Column]
- // private ?int $templateSystem_id;
- //
- // #[ORM\Column]
- // private ?int $work_id;
- #[ORM\OneToMany(mappedBy: 'image', targetEntity: Person::class, orphanRemoval: true)]
- private Collection $personImages;
- #[ORM\OneToMany(mappedBy: 'logo', targetEntity: Organization::class, orphanRemoval: true)]
- private Collection $organizationLogos;
- #[ORM\OneToMany(mappedBy: 'image', targetEntity: Organization::class, orphanRemoval: true)]
- private Collection $organizationImages;
- #[Pure] public function __construct()
- {
- $this->personImages = new ArrayCollection();
- $this->organizationLogos = new ArrayCollection();
- $this->organizationImages = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- /**
- * @return Person
- */
- public function getPerson(): Person
- {
- return $this->person;
- }
- /**
- * @param Person $person
- */
- public function setPerson(Person $person): void
- {
- $this->person = $person;
- }
- /**
- * @return Organization
- */
- public function getOrganization(): Organization
- {
- return $this->organization;
- }
- /**
- * @param Organization $organization
- */
- public function setOrganization(Organization $organization): void
- {
- $this->organization = $organization;
- }
- public function getSlug(): string
- {
- return $this->slug;
- }
- public function setSlug(string $slug): self
- {
- $this->slug = $slug;
- return $this;
- }
- public function getPath(): string
- {
- return $this->path;
- }
- public function setPath(string $path): self
- {
- $this->path = $path;
- return $this;
- }
- public function getName(): string
- {
- return $this->name;
- }
- public function setName(string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getMimeType(): ?string
- {
- return $this->mimeType;
- }
- public function setMimeType(?string $mimeType): self
- {
- $this->mimeType = $mimeType;
- return $this;
- }
- public function getConfig(): string
- {
- return $this->config;
- }
- public function setConfig(string $config): self
- {
- $this->config = $config;
- return $this;
- }
- public function getPersonImages(): Collection
- {
- return $this->personImages;
- }
- public function addPersonImage (Person $person): self
- {
- if (!$this->personImages->contains($person)) {
- $this->personImages[] = $person;
- $person->setImage($this);
- }
- return $this;
- }
- public function removePersonImage(Person $person): self
- {
- if ($this->personImages->removeElement($person)) {
- // set the owning side to null (unless already changed)
- if ($person->getImage() === $this) {
- $person->setImage(null);
- }
- }
- return $this;
- }
- /**
- * @return string
- */
- public function getVisibility(): string
- {
- return $this->visibility;
- }
- /**
- * @param string $visibility
- */
- public function setVisibility(string $visibility): void
- {
- $this->visibility = $visibility;
- }
- /**
- * @return string
- */
- public function getFolder(): string
- {
- return $this->folder;
- }
- /**
- * @param string $folder
- */
- public function setFolder(string $folder): void
- {
- $this->folder = $folder;
- }
- /**
- * @return string
- */
- public function getType(): string
- {
- return $this->type;
- }
- /**
- * @param string $type
- */
- public function setType(string $type): void
- {
- $this->type = $type;
- }
- /**
- * @return int|null
- */
- public function getSize(): ?int
- {
- return $this->size;
- }
- /**
- * @param int|null $size
- */
- public function setSize(?int $size): void
- {
- $this->size = $size;
- }
- /**
- * @return bool
- */
- public function getIsTemporaryFile(): bool
- {
- return $this->isTemporaryFile;
- }
- /**
- * @param bool $isTemporaryFile
- */
- public function setIsTemporaryFile(bool $isTemporaryFile): void
- {
- $this->isTemporaryFile = $isTemporaryFile;
- }
- /**
- * @return DateTime
- */
- public function getCreateDate(): DateTime
- {
- return $this->createDate;
- }
- /**
- * @param DateTime $createDate
- */
- public function setCreateDate(DateTime $createDate): void
- {
- $this->createDate = $createDate;
- }
- /**
- * @return int|null
- */
- public function getCreatedBy(): ?int
- {
- return $this->createdBy;
- }
- /**
- * @param int|null $createdBy
- */
- public function setCreatedBy(?int $createdBy): void
- {
- $this->createdBy = $createdBy;
- }
- /**
- * @return DateTime
- */
- public function getUpdateDate(): DateTime
- {
- return $this->updateDate;
- }
- /**
- * @param DateTime $updateDate
- */
- public function setUpdateDate(DateTime $updateDate): void
- {
- $this->updateDate = $updateDate;
- }
- /**
- * @return int|null
- */
- public function getUpdatedBy(): ?int
- {
- return $this->updatedBy;
- }
- /**
- * @param int|null $updatedBy
- */
- public function setUpdatedBy(?int $updatedBy): void
- {
- $this->updatedBy = $updatedBy;
- }
- public function getOrganizationLogos(): Collection
- {
- return $this->organizationLogos;
- }
- public function addOrganizationLogo(Organization $organization): self
- {
- if (!$this->organizationLogos->contains($organization)) {
- $this->organizationLogos[] = $organization;
- $organization->setLogo($this);
- }
- return $this;
- }
- public function removeOrganizationLogo(Organization $organization): self
- {
- if ($this->organizationLogos->removeElement($organization)) {
- // set the owning side to null (unless already changed)
- if ($organization->getLogo() === $this) {
- $organization->setLogo(null);
- }
- }
- return $this;
- }
- public function getOrganizationImages(): Collection
- {
- return $this->organizationImages;
- }
- public function addOrganizationImage(Organization $organization): self
- {
- if (!$this->organizationImages->contains($organization)) {
- $this->organizationImages[] = $organization;
- $organization->setImage($this);
- }
- return $this;
- }
- public function removeOrganizationImage(Organization $organization): self
- {
- if ($this->organizationImages->removeElement($organization)) {
- // set the owning side to null (unless already changed)
- if ($organization->getImage() === $this) {
- $organization->setImage(null);
- }
- }
- return $this;
- }
- }
|