src/Entity/Image.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Service\ImageService;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Table(name'image')]
  6. #[ORM\Index(name'IX_type_reference_id'columns: ['type''reference_id'])]
  7. #[ORM\Index(name'IX_hash'columns: ['hash'])]
  8. #[ORM\Entity(repositoryClass'App\Entity\Repository\ImageRepository')]
  9. class Image
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\Column(type'integer')]
  13.     #[ORM\GeneratedValue(strategy'AUTO')]
  14.     private $id;
  15.     #[ORM\Column(type'string'nullabletrue)]
  16.     private $type;
  17.     #[ORM\Column(type'string'nullabletrue)]
  18.     private $path;
  19.     #[ORM\Column(type'integer'nullabletrue)]
  20.     private $reference_id;
  21.     #[ORM\Column(type'string'nullabletrue)]
  22.     private $license;
  23.     #[ORM\Column(type'datetime'nullabletrue)]
  24.     private $date_created;
  25.     #[ORM\ManyToOne(targetEntity'App\Entity\User'inversedBy'image')]
  26.     #[ORM\JoinColumn(name'user_id'referencedColumnName'id')]
  27.     private $user;
  28.     #[ORM\Column(type'boolean'nullabletrue)]
  29.     private $useS3;
  30.     #[ORM\Column(type'string'length32nullabletrue)]
  31.     private $hash;
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getType(): ?string
  37.     {
  38.         return $this->type;
  39.     }
  40.     public function setType(?string $type): self
  41.     {
  42.         $this->type $type;
  43.         return $this;
  44.     }
  45.     public function getPath(): ?string
  46.     {
  47.         return $this->path;
  48.     }
  49.     public function setPath(?string $path): self
  50.     {
  51.         $this->path $path;
  52.         return $this;
  53.     }
  54.     public function getReferenceId(): ?int
  55.     {
  56.         return $this->reference_id;
  57.     }
  58.     public function setReferenceId(?int $reference_id): self
  59.     {
  60.         $this->reference_id $reference_id;
  61.         return $this;
  62.     }
  63.     public function getLicense(): ?string
  64.     {
  65.         return $this->license;
  66.     }
  67.     public function setLicense(?string $license): self
  68.     {
  69.         $this->license $license;
  70.         return $this;
  71.     }
  72.     public function getDateCreated(): ?\DateTimeInterface
  73.     {
  74.         return $this->date_created;
  75.     }
  76.     public function setDateCreated(?\DateTimeInterface $date_created): self
  77.     {
  78.         $this->date_created $date_created;
  79.         return $this;
  80.     }
  81.     public function getUser(): ?User
  82.     {
  83.         return $this->user;
  84.     }
  85.     public function setUser(?User $user): self
  86.     {
  87.         $this->user $user;
  88.         return $this;
  89.     }
  90.     public function isRestricted(): bool
  91.     {
  92.         // which images are restricted
  93.         $restrictedTypes = [
  94.             ImageService::TYPE_CROP,
  95.             ImageService::TYPE_GARDEN
  96.         ];
  97.         return in_array($this->type$restrictedTypes);
  98.     }
  99.     public function getUseS3(): ?bool
  100.     {
  101.         return $this->useS3;
  102.     }
  103.     public function setUseS3(?bool $useS3): self
  104.     {
  105.         $this->useS3 $useS3;
  106.         return $this;
  107.     }
  108.     public function getHash(): ?string
  109.     {
  110.         return $this->hash;
  111.     }
  112.     public function setHash(?string $hash): self
  113.     {
  114.         $this->hash $hash;
  115.         return $this;
  116.     }
  117. }