src/Entity/MediaObject/MediaThumbnailGift.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Entity\MediaObject;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Catalog\Gift;
  6. use App\Repository\MediaObject\MediaThumbnailGiftRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. /**
  14.  * @ApiResource(
  15.  *      attributes={
  16.  *          "normalization_context"={"groups"={
  17.  *              "media_object_read",
  18.  *              "MediaThumbnailGift:output",
  19.  *              "MediaThumbnailGift:io",
  20.  *              "Gift:output",
  21.  *          }},
  22.  *          "denormalization_context"={"groups"={
  23.  *              "media_object_read",
  24.  *              "MediaThumbnailGift:input",
  25.  *              "MediaThumbnailGift:io",
  26.  *              "Gift:input",
  27.  *          }}
  28.  *      },
  29.  *     iri="http://schema.org/MediaThumbnailGift",
  30.  *     collectionOperations={
  31.  *         "get"
  32.  *     },
  33.  *     itemOperations={
  34.  *         "get"
  35.  *     }
  36.  * )
  37.  * @ORM\Entity(repositoryClass=MediaThumbnailGiftRepository::class)
  38.  * @Vich\Uploadable
  39.  */
  40. class MediaThumbnailGift extends MediaObject
  41. {
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity=Gift::class, inversedBy="mediaThumbnailGifts", cascade={"persist"})
  44.      * @ORM\JoinColumn(nullable=true, name="object_id")
  45.      * @SerializedName("gift")
  46.      */
  47.     private $gift;
  48.     /**
  49.      * @var string|null
  50.      * @ApiProperty(iri="http://schema.org/contentUrl")
  51.      * @SerializedName("content_url")
  52.      * @Groups({
  53.      *     "MediaObject:output",
  54.      *     "MediaThumbnailGift:output",
  55.      *     "media_object_read",
  56.      *     "Gift:output",
  57.      *     "get_user_gift_carts",
  58.      *     "get_order_by_user",
  59.      *     "Order:output",
  60.      * })
  61.      */
  62.     private $contentUrl;
  63.     /**
  64.      * @var File|null
  65.      * @Assert\NotNull(
  66.      *     groups={
  67.      *     "media_object_read",
  68.      *     "MediaThumbnailGift:io",
  69.      *     "MediaObject:output",
  70.      *     "get_user_gift_carts",
  71.      * })
  72.      * @Vich\UploadableField(mapping="gift_image", fileNameProperty="filePath")
  73.      * @Groups({
  74.      *     "Gift:output",
  75.      *     "MediaThumbnailGift:output",
  76.      *     "get_user_gift_carts",
  77.      *     "get_order_by_user",
  78.      *     "Order:output",
  79.      * })
  80.      */
  81.     public $file;
  82.     /**
  83.      * @var string|null
  84.      *
  85.      * @ORM\Column(nullable=true)
  86.      * @SerializedName("file_path")
  87.      * @Groups({
  88.      *     "Gift:output",
  89.      *     "MediaThumbnailGift:output",
  90.      *     "get_user_gift_carts",
  91.      *     "get_order_by_user",
  92.      *     "Order:output",
  93.      * })
  94.      */
  95.     public $filePath;
  96.     /**
  97.      * @return mixed
  98.      */
  99.     public function getGift()
  100.     {
  101.         return $this->gift;
  102.     }
  103.     public function setGift($gift)
  104.     {
  105.         $this->gift $gift;
  106.         return $this;
  107.     }
  108.     public function getContentUrl(): ?string
  109.     {
  110.         return $this->contentUrl;
  111.     }
  112.     public function setContentUrl(?string $contentUrl): MediaThumbnailGift
  113.     {
  114.         $this->contentUrl $contentUrl;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return string|null
  119.      */
  120.     public function __toString()
  121.     {
  122.         return "".$this->gift;
  123.     }
  124. }