src/Entity/CRM/AudioAsset.php line 15

  1. <?php
  2. namespace App\Entity\CRM;
  3. use App\Repository\CRM\AudioAssetRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. #[ORM\Entity(repositoryClassAudioAssetRepository::class)]
  11. #[Vich\Uploadable]
  12. class AudioAsset
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[Vich\UploadableField(mapping'audio_assets'fileNameProperty'fileName'size'fileSize'mimeType'mimeType'originalName'originalName')]
  19.     private ?File $file null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $fileName null;
  22.     #[ORM\Column(nullabletrue)]
  23.     private ?int $fileSize null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?string $mimeType null;
  26.     #[ORM\Column(length255nullabletrue)]
  27.     private ?string $originalName null;
  28.     #[ORM\Column(nullabletrue)]
  29.     private ?float $duration null;
  30.     #[ORM\ManyToOne(targetEntityAdmin::class, inversedBy'audioAssets')]
  31.     private ?Admin $createdBy null;
  32.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  33.     private \DateTimeInterface $createdAt;
  34.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  35.     private ?\DateTimeInterface $updatedAt null;
  36.     #[ORM\OneToMany(mappedBy'audioAsset'targetEntityAudioEditJob::class, cascade: ['remove'])]
  37.     private Collection $jobs;
  38.     public function __construct()
  39.     {
  40.         $this->createdAt = new \DateTime();
  41.         $this->jobs = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function setFile(?File $file null): void
  48.     {
  49.         $this->file $file;
  50.         if (null !== $file) {
  51.             $this->updatedAt = new \DateTime();
  52.         }
  53.     }
  54.     public function getFile(): ?File
  55.     {
  56.         return $this->file;
  57.     }
  58.     public function getFileName(): ?string
  59.     {
  60.         return $this->fileName;
  61.     }
  62.     public function setFileName(?string $fileName): self
  63.     {
  64.         $this->fileName $fileName;
  65.         return $this;
  66.     }
  67.     public function getFileSize(): ?int
  68.     {
  69.         return $this->fileSize;
  70.     }
  71.     public function setFileSize(?int $fileSize): self
  72.     {
  73.         $this->fileSize $fileSize;
  74.         return $this;
  75.     }
  76.     public function getMimeType(): ?string
  77.     {
  78.         return $this->mimeType;
  79.     }
  80.     public function setMimeType(?string $mimeType): self
  81.     {
  82.         $this->mimeType $mimeType;
  83.         return $this;
  84.     }
  85.     public function getOriginalName(): ?string
  86.     {
  87.         return $this->originalName;
  88.     }
  89.     public function setOriginalName(?string $originalName): self
  90.     {
  91.         $this->originalName $originalName;
  92.         return $this;
  93.     }
  94.     public function getDuration(): ?float
  95.     {
  96.         return $this->duration;
  97.     }
  98.     public function setDuration(?float $duration): self
  99.     {
  100.         $this->duration $duration;
  101.         return $this;
  102.     }
  103.     public function getCreatedBy(): ?Admin
  104.     {
  105.         return $this->createdBy;
  106.     }
  107.     public function setCreatedBy(?Admin $createdBy): self
  108.     {
  109.         $this->createdBy $createdBy;
  110.         return $this;
  111.     }
  112.     public function getCreatedAt(): \DateTimeInterface
  113.     {
  114.         return $this->createdAt;
  115.     }
  116.     public function getUpdatedAt(): ?\DateTimeInterface
  117.     {
  118.         return $this->updatedAt;
  119.     }
  120.     /**
  121.      * @return Collection<int, AudioEditJob>
  122.      */
  123.     public function getJobs(): Collection
  124.     {
  125.         return $this->jobs;
  126.     }
  127.     public function addJob(AudioEditJob $job): self
  128.     {
  129.         if (!$this->jobs->contains($job)) {
  130.             $this->jobs->add($job);
  131.             $job->setAudioAsset($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeJob(AudioEditJob $job): self
  136.     {
  137.         if ($this->jobs->removeElement($job)) {
  138.             if ($job->getAudioAsset() === $this) {
  139.                 $job->setAudioAsset(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144.     public function __toString(): string
  145.     {
  146.         return (string) ($this->originalName ?? $this->fileName ?? 'audio');
  147.     }
  148. }