<?php
namespace App\Entity\MediaObject;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Catalog\Gift;
use App\Repository\MediaObject\MediaGiftRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={
* "media_object_read",
* "MediaGift:output",
* "MediaGift:io",
* "Gift:output",
* }},
* "denormalization_context"={"groups"={
* "media_object_read",
* "MediaGift:input",
* "MediaGift:io",
* "Gift:input",
* }}
* },
* iri="http://schema.org/MediaGift",
* collectionOperations={
* "get"
* },
* itemOperations={
* "get"
* }
* )
* @ORM\Entity(repositoryClass=MediaGiftRepository::class)
* @Vich\Uploadable()
*/
class MediaGift extends MediaObject
{
/**
* @ORM\ManyToOne(targetEntity=Gift::class, inversedBy="mediaGifts", cascade={"persist"})
* @ORM\JoinColumn(nullable=true, name="object_id")
* @SerializedName("gift")
*/
private $gift;
/**
* @var string|null
* @ApiProperty(iri="http://schema.org/contentUrl")
* @SerializedName("content_url")
* @Groups({
* "MediaObject:output",
* "MediaGift:output",
* "media_object_read",
* "Gift:output",
* "get_user_gift_carts",
* "get_order_by_user",
* "Order:output",
* })
*/
private $contentUrl;
/**
* @var File|null
* @Assert\NotNull(
* groups={
* "media_object_read",
* "MediaGift:io",
* })
* @Vich\UploadableField(mapping="gift_image", fileNameProperty="filePath")
* @Groups({
* "Gift:output",
* "MediaGift:output",
* "get_user_gift_carts",
* "get_order_by_user",
* "Order:output",
* })
*/
public $file;
/**
* @var string|null
*
* @ORM\Column(nullable=true)
* @SerializedName("file_path")
* @Groups({
* "Gift:output",
* "MediaGift:ouput",
* "get_user_gift_carts",
* "get_order_by_user",
* "Order:output",
* })
*/
public $filePath;
/**
* @return mixed
*/
public function getGift()
{
return $this->gift;
}
public function setGift($gift)
{
$this->gift = $gift;
return $this;
}
/**
* @return string|null
*/
public function getContentUrl(): ?string
{
return $this->contentUrl;
}
/**
* @param string|null $contentUrl
* @return MediaGift
*/
public function setContentUrl(?string $contentUrl): MediaGift
{
$this->contentUrl = $contentUrl;
return $this;
}
/**
* @return string|null
*/
public function __toString()
{
return "".$this->gift;
}
}