src/Entity/MediaObject/MediaCoupon.php line 70

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\Controller\Api\MediaObject\CreateMediaCouponAction;
  6. use App\Entity\Details\Operation\DetailsCoupon;
  7. use App\Repository\MediaObject\MediaCouponRepository;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Serializer\Annotation\SerializedName;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. /**
  15.  * @ApiResource(
  16.  *     attributes={
  17.  *          "normalization_context"={"groups"={
  18.  *              "media_object_read",
  19.  *              "MediaCoupon:output",
  20.  *              "MediaCoupon:io",
  21.  *          }},
  22.  *          "denormalization_context"={"groups"={
  23.  *              "media_object_read",
  24.  *              "MediaCoupon:input",
  25.  *              "MediaCoupon:io",
  26.  *          }}
  27.  *      },
  28.  *     iri="http://schema.org/MediaCoupon",
  29.  *     collectionOperations={
  30.  *         "post"={
  31.  *             "controller"=CreateMediaCouponAction::class,
  32.  *             "deserialize"=false,
  33.  *             "security"="is_granted('ROLE_ADMIN_SOGEC')",
  34.  *             "validation_groups"={
  35.  *                  "Default",
  36.  *                  "media_object_create",
  37.  *                  "MediaCoupon:io",
  38.  *              },
  39.  *             "openapi_context"={
  40.  *                 "requestBody"={
  41.  *                     "content"={
  42.  *                         "multipart/form-data"={
  43.  *                             "schema"={
  44.  *                                 "type"="object",
  45.  *                                 "properties"={
  46.  *                                     "file"={
  47.  *                                         "type"="string",
  48.  *                                         "format"="binary"
  49.  *                                     }
  50.  *                                 }
  51.  *                             }
  52.  *                         }
  53.  *                     }
  54.  *                 }
  55.  *             }
  56.  *         },
  57.  *         "get"
  58.  *     },
  59.  *     itemOperations={
  60.  *         "get"
  61.  *     }
  62.  * )
  63.  *
  64.  * @ORM\Entity(repositoryClass=MediaCouponRepository::class)
  65.  * @Vich\Uploadable
  66.  */
  67. class MediaCoupon extends MediaObject
  68. {
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=DetailsCoupon::class, inversedBy="images")
  71.      * @ORM\JoinColumn(nullable=true, name="object_id")
  72.      * @SerializedName("details_coupon")
  73.      */
  74.     private $detailsCoupon;
  75.     /**
  76.      * @var string|null
  77.      * @ApiProperty(iri="http://schema.org/contentUrl")
  78.      * @SerializedName("content_url")
  79.      * @Groups({
  80.      *     "MediaObject:output",
  81.      *     "MediaCoupon:output",
  82.      *     "media_object_read",
  83.      *     "get_all_public_coupons",
  84.      *     "get_coupons_by_user_department",
  85.      * })
  86.      */
  87.     private $contentUrl;
  88.     /**
  89.      * @var File|null
  90.      * @Assert\NotNull(
  91.      *     groups={
  92.      *     "media_object_read",
  93.      *     "MediaCoupon:io",
  94.      *     "MediaObject:output",
  95.      * })
  96.      * @Vich\UploadableField(mapping="coupon", fileNameProperty="filePath")
  97.      */
  98.     public $file;
  99.     /**
  100.      * @var string|null
  101.      * @Groups({
  102.      *     "get_all_public_coupons",
  103.      *     "get_coupons_by_user_department",
  104.      * })
  105.      * @ORM\Column(nullable=true)
  106.      * @SerializedName("file_path")
  107.      * @Groups({
  108.      *     "OperationCoupon:output",
  109.      * })
  110.      */
  111.     public $filePath;
  112.     public function setDetailsCoupon($detailsCoupon): MediaCoupon
  113.     {
  114.         $this->detailsCoupon $detailsCoupon;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return string|null
  119.      */
  120.     public function getContentUrl(): ?string
  121.     {
  122.         return $this->contentUrl;
  123.     }
  124.     /**
  125.      * @param string|null $contentUrl
  126.      * @return MediaCoupon
  127.      */
  128.     public function setContentUrl(?string $contentUrl): MediaCoupon
  129.     {
  130.         $this->contentUrl $contentUrl;
  131.         return $this;
  132.     }
  133. }