src/Entity/Media.php line 95
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraint;
use ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get,
ApiPlatform\Metadata\Post;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use App\Repository\MediaRepository;
use App\Controller\CreateMediaAction,
App\DTO\CloneDTO,
App\StateProcessor\CloneProcessor,
App\Security\Voter\CloneVoter,
App\Lib\Actions;
use App\Controller\CreateResizeMediaAction,
App\StateProcessor\PostCreateResizeMediaProcessor;
#[ApiResource(
normalizationContext: ['groups' => ['read', 'read:' . self::class]],
operations: [
new Get(),
new Post(
uriTemplate: '/media/clone',
input: CloneDTO::class,
processor: CloneProcessor::class,
security: 'is_granted("' . Actions::CLONE .'")',
securityMessage: CloneVoter::MESSAGE
),
new Post(
controller: CreateMediaAction::class,
deserialize: false,
validationContext: ['groups' => [Constraint::DEFAULT_GROUP, 'post']],
openapiContext: [
'requestBody' => [
'content' => [
'multipart/form-data' => [
'schema' => [
'type' => 'object',
'properties' => [
'file' => [
'type' => 'string',
'format' => 'binary'
]
]
]
]
]
]
]
),
new Post(
uriTemplate: '/media/resize',
controller: CreateResizeMediaAction::class,
processor: PostCreateResizeMediaProcessor::class,
deserialize: false,
validationContext: ['groups' => [Constraint::DEFAULT_GROUP, 'post']],
openapiContext: [
'requestBody' => [
'content' => [
'multipart/form-data' => [
'schema' => [
'type' => 'object',
'properties' => [
'file' => [
'type' => 'string',
'format' => 'binary'
],
'width' => [
'type' => 'integer',
'format' => 'int32'
],
'height' => [
'type' => 'integer',
'format' => 'int32'
]
]
]
]
]
]
],
),
],
extraProperties: ['standard_put' => false],
)]
#[Vich\Uploadable]
#[ORM\Entity(repositoryClass: MediaRepository::class)]
class Media extends AbstractMedia
{
}