|
|
|
@@ -13,13 +13,16 @@ use Symfony\Component\HttpFoundation\Request; |
|
|
|
use Symfony\Component\HttpKernel\Attribute\AsController; |
|
|
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
|
|
|
use Symfonycasts\MicroMapper\MicroMapperInterface; |
|
|
|
use ApiPlatform\Core\Api\IriConverterInterface; |
|
|
|
use Symfony\Component\Serializer\SerializerInterface; |
|
|
|
|
|
|
|
#[AsController] |
|
|
|
final class CreateMediaObjectAction extends AbstractController |
|
|
|
{ |
|
|
|
public function __construct( |
|
|
|
private MicroMapperInterface $microMapper, |
|
|
|
private EntityManagerInterface $em |
|
|
|
private EntityManagerInterface $em, |
|
|
|
private SerializerInterface $serializer |
|
|
|
) { |
|
|
|
} |
|
|
|
|
|
|
|
@@ -42,6 +45,11 @@ final class CreateMediaObjectAction extends AbstractController |
|
|
|
$this->em->flush(); |
|
|
|
|
|
|
|
$mediaObjectApi = $this->microMapper->map($mediaObject, MediaObjectApi::class); |
|
|
|
return new JsonResponse($mediaObjectApi); |
|
|
|
|
|
|
|
// Serialisieren Sie das Objekt mit dem API Platform Serializer |
|
|
|
$jsonContent = $this->serializer->serialize($mediaObjectApi, 'jsonld', ['groups' => 'media_object:read']); |
|
|
|
|
|
|
|
// Erstellen Sie eine JsonResponse mit dem serialisierten Inhalt |
|
|
|
return new JsonResponse($jsonContent, 200, [], true); |
|
|
|
} |
|
|
|
} |