<?php
namespace App\Entity\MediaObject;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\MediaObject\MediaImageRepository;
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",
* "MediaImage:output",
* "MediaImage:io",
* }},
* "denormalization_context"={"groups"={
* "media_object_read",
* "MediaImage:input",
* "MediaImage:io",
* }}
* },
* iri="http://schema.org/MediaImage",
* collectionOperations={
* "get"
* },
* itemOperations={
* "get"
* }
* )
*
* @ORM\Entity(repositoryClass=MediaImageRepository::class)
* @Vich\Uploadable
*/
class MediaImage extends MediaObject
{
/**
* @var string|null
* @ORM\JoinColumn(nullable=true, name="object_id")
*/
private ?string $object_id = null;
/**
* @var string|null
* @ApiProperty(iri="http://schema.org/contentUrl")
* @SerializedName("content_url")
* @Groups({
* "MediaObject:output",
* "MediaImage:output",
* "media_object_read",
* })
*/
private $contentUrl;
/**
* @var File|null
* @Assert\NotNull(
* groups={
* "media_object_read",
* "MediaImage:io",
* "MediaObject:output",
* })
* @Assert\File(
* maxSize = "500k",
* mimeTypes = {"image/jpeg", "image/jpg", "image/png", "image/gif"},
* maxSizeMessage = "La taille de l'image maximale autorisée est de 500 Ko.",
* mimeTypesMessage = "Seules les images au format .jpeg / .jpg / .png / .gif sont autorisées."
* )
* @Vich\UploadableField(mapping="library_image", fileNameProperty="filePath")
* @Groups({
* "MediaImage:output",
* })
*/
public $file;
/**
* @var string|null
*
* @ORM\Column(nullable=true)
* @SerializedName("file_path")
* @Groups({
* "MediaImage:output",
* })
*/
public $filePath;
/**
* @return string|null
*/
public function getContentUrl(): ?string
{
return $this->contentUrl;
}
/**
* @param string|null $contentUrl
* @return MediaImage
*/
public function setContentUrl(?string $contentUrl): MediaImage
{
$this->contentUrl = $contentUrl;
return $this;
}
/**
* @return string|null
*/
public function getObjectId(): ?string
{
return $this->object_id;
}
/**
* @param string|null $object_id
* @return MediaImage
*/
public function setObjectId(?string $object_id): MediaImage
{
$this->contentUrl = $object_id;
return $this;
}
}