src/Entity/MediaObject/MediaCodeDraw.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\MediaObject;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use App\Entity\Operation\Draw;
  5. use App\Repository\MediaObject\MediaCodeDrawRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Serializer\Annotation\SerializedName;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. /**
  13.  * @ORM\Entity(repositoryClass=MediaCodeDrawRepository::class)
  14.  * @Vich\Uploadable
  15.  */
  16. class MediaCodeDraw extends MediaObject
  17. {
  18.     public const MIME_TEXT_PLAIN 'text/plain';
  19.     public const MIME_CSV 'text/csv';
  20.     public const MIME_XLSX 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
  21.     public const ARRAY_MIME = [
  22.         self::MIME_TEXT_PLAIN,
  23.         self::MIME_CSV,
  24.         self::MIME_XLSX,
  25.     ];
  26.     public const EXTENSION_CSV 'csv';
  27.     public const EXTENSION_XLSX 'xlsx';
  28.     public const COLUMN_CODE 'code';
  29.     public const ARRAY_COLUMN = [
  30.         self::COLUMN_CODE,
  31.     ];
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity=Draw::class, inversedBy="mediaCodeDraws", cascade={"persist"})
  34.      * @ORM\JoinColumn(nullable=true, name="object_id")
  35.      * @SerializedName("draw")
  36.      */
  37.     private $draw;
  38.     /**
  39.      * @var string|null
  40.      * @ApiProperty(iri="http://schema.org/contentUrl")
  41.      * @SerializedName("content_url")
  42.      * @Groups({
  43.      *     "MediaObject:output",
  44.      *     "MediaCodeDraw:output",
  45.      *     "media_object_read",
  46.      *     "Gift:output",
  47.      * })
  48.      */
  49.     private $contentUrl;
  50.     /**
  51.      * @var File|null
  52.      * @Assert\NotNull(
  53.      *     groups={
  54.      *     "media_object_read",
  55.      *     "MediaCodeDraw:io",
  56.      *     "MediaObject:output",
  57.      * })
  58.      * @Vich\UploadableField(mapping="draw_code", fileNameProperty="filePath")
  59.      * @Groups({
  60.      *     "Gift:output",
  61.      * })
  62.      */
  63.     public $file;
  64.     /**
  65.      * @var string|null
  66.      *
  67.      * @ORM\Column(nullable=true)
  68.      * @SerializedName("file_path")
  69.      * @Groups({
  70.      *     "Gift:output",
  71.      * })
  72.      */
  73.     public $filePath;
  74.     /**
  75.      * @return Draw
  76.      */
  77.     public function getDraw(): Draw
  78.     {
  79.         return $this->draw;
  80.     }
  81.     public function setDraw($draw): self
  82.     {
  83.         $this->draw $draw;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return string|null
  88.      */
  89.     public function getContentUrl(): ?string
  90.     {
  91.         return $this->contentUrl;
  92.     }
  93.     /**
  94.      * @param string|null $contentUrl
  95.      * @return MediaCodeDraw
  96.      */
  97.     public function setContentUrl(?string $contentUrl): MediaCodeDraw
  98.     {
  99.         $this->contentUrl $contentUrl;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @return string|null
  104.      */
  105.     public function __toString()
  106.     {
  107.         return "".$this->contentUrl;
  108.     }
  109. }