src/Entity/MediaObject/MediaCodeGift.php line 44

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\MediaCodeGiftRepository;
  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.  *              "MediaCodeGift:output",
  19.  *              "MediaCodeGift:io",
  20.  *              "Blog:output",
  21.  *          }},
  22.  *          "denormalization_context"={"groups"={
  23.  *              "media_object_read",
  24.  *              "MediaCodeGift:input",
  25.  *              "MediaCodeGift:io",
  26.  *              "Blog:input",
  27.  *          }}
  28.  *      },
  29.  *     iri="http://schema.org/MediaCodeGift",
  30.  *     collectionOperations={
  31.  *         "get"
  32.  *     },
  33.  *     itemOperations={
  34.  *         "get"
  35.  *     }
  36.  * )
  37.  *
  38.  * @ORM\Entity(repositoryClass=MediaCodeGiftRepository::class)
  39.  * @Vich\Uploadable
  40.  */
  41. class MediaCodeGift extends MediaObject
  42. {
  43.     public const MIME_TEXT_PLAIN 'text/plain';
  44.     public const MIME_CSV 'text/csv';
  45.     public const MIME_XLSX 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
  46.     public const ARRAY_MIME = [
  47.         self::MIME_TEXT_PLAIN,
  48.         self::MIME_CSV,
  49.         self::MIME_XLSX,
  50.     ];
  51.     public const EXTENSION_CSV 'csv';
  52.     public const EXTENSION_XLSX 'xlsx';
  53.     public const COLUMN_CODE 'code';
  54.     public const ARRAY_COLUMN = [
  55.         self::COLUMN_CODE,
  56.     ];
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity=Gift::class, inversedBy="mediaCodeGifts", cascade={"persist"})
  59.      * @ORM\JoinColumn(nullable=true, name="object_id")
  60.      * @SerializedName("gift")
  61.      */
  62.     private $gift;
  63.     /**
  64.      * @var string|null
  65.      * @ApiProperty(iri="http://schema.org/contentUrl")
  66.      * @SerializedName("content_url")
  67.      * @Groups({
  68.      *     "MediaObject:output",
  69.      *     "MediaCodeGift:output",
  70.      *     "media_object_read",
  71.      *     "Gift:output",
  72.      * })
  73.      */
  74.     private $contentUrl;
  75.     /**
  76.      * @var File|null
  77.      * @Assert\NotNull(
  78.      *     groups={
  79.      *     "media_object_read",
  80.      *     "MediaCodeGift:io",
  81.      *     "MediaObject:output",
  82.      * })
  83.      * @Vich\UploadableField(mapping="gift_code", fileNameProperty="filePath")
  84.      * @Groups({
  85.      *     "Gift:output",
  86.      * })
  87.      */
  88.     public $file;
  89.     /**
  90.      * @var string|null
  91.      *
  92.      * @ORM\Column(nullable=true)
  93.      * @SerializedName("file_path")
  94.      * @Groups({
  95.      *     "Gift:output",
  96.      * })
  97.      */
  98.     public $filePath;
  99.     /**
  100.      * @return Gift
  101.      */
  102.     public function getGift(): Gift
  103.     {
  104.         return $this->gift;
  105.     }
  106.     public function setGift($gift): self
  107.     {
  108.         $this->gift $gift;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return string|null
  113.      */
  114.     public function getContentUrl(): ?string
  115.     {
  116.         return $this->contentUrl;
  117.     }
  118.     /**
  119.      * @param string|null $contentUrl
  120.      * @return MediaCodeGift
  121.      */
  122.     public function setContentUrl(?string $contentUrl): MediaCodeGift
  123.     {
  124.         $this->contentUrl $contentUrl;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return string|null
  129.      */
  130.     public function __toString()
  131.     {
  132.         return "".$this->contentUrl;
  133.     }
  134. }