src/Entity/Gallery/Photo.php line 13

  1. <?php
  2. namespace App\Entity\Gallery;
  3. use App\Entity\Common\File;
  4. use App\Entity\Traits\UserCreatedInterface;
  5. use App\Entity\Traits\UserUpdatedInterface;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Table(name'gallery_photo')]
  8. #[ORM\Entity(repositoryClass'App\Repository\Gallery\PhotoRepository')]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Photo implements UserCreatedInterfaceUserUpdatedInterfaceAlbumItemInterface
  11. {
  12.     use \App\Entity\Traits\TrackerFields;
  13.     use \App\Entity\Traits\ActiveTrait;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue(strategy'AUTO')]
  16.     #[ORM\Column(type'integer')]
  17.     private ?int $id;
  18.     #[ORM\Column(type'integer')]
  19.     private int $weight 50;
  20.     #[ORM\Column(type'string'length15enumTypeItemType::class, options: ['default' => 'photo'])]
  21.     private ItemType $type ItemType::Photo;
  22.     #[ORM\ManyToOne(targetEntity\App\Entity\Common\File::class, cascade: ['persist''remove'])]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private File $file;
  25.     #[ORM\ManyToOne(targetEntity\App\Entity\Gallery\Album::class, inversedBy'photos')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private Album $album;
  28.     #[ORM\Column(type'json'nullabletrue)]
  29.     private ?array $data = [];
  30.     /**
  31.      * @return int|null
  32.      */
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     /**
  38.      * @param int|null $id
  39.      */
  40.     public function setId(?int $id): void
  41.     {
  42.         $this->id $id;
  43.     }
  44.     /**
  45.      * @return int
  46.      */
  47.     public function getWeight(): int
  48.     {
  49.         return $this->weight;
  50.     }
  51.     /**
  52.      * @param int $weight
  53.      */
  54.     public function setWeight(int $weight): void
  55.     {
  56.         $this->weight $weight;
  57.     }
  58.     /**
  59.      * @return mixed
  60.      */
  61.     public function getFile(): File
  62.     {
  63.         return $this->file;
  64.     }
  65.     /**
  66.      * @param mixed $file
  67.      */
  68.     public function setFile(File $file): void
  69.     {
  70.         $this->file $file;
  71.     }
  72.     /**
  73.      * @return Album
  74.      */
  75.     public function getAlbum(): Album
  76.     {
  77.         return $this->album;
  78.     }
  79.     /**
  80.      * @param Album $album
  81.      */
  82.     public function setAlbum(Album $album): void
  83.     {
  84.         $this->album $album;
  85.     }
  86.     /**
  87.      * @return ItemType
  88.      */
  89.     public function getType(): ItemType
  90.     {
  91.         return $this->type;
  92.     }
  93.     /**
  94.      * @param ItemType $type
  95.      */
  96.     public function setType(ItemType $type): void
  97.     {
  98.         $this->type $type;
  99.     }
  100.     public function getData(): array
  101.     {
  102.         if (is_null($this->data)) return [];
  103.         return $this->data;
  104.     }
  105.     /**
  106.      * @param array|null $data
  107.      */
  108.     public function setData(?array $data): void
  109.     {
  110.         $this->data $data;
  111.     }
  112. }