diff --git a/src/Controller/DeleteMediaObjectAction.php b/src/Controller/DeleteMediaObjectAction.php deleted file mode 100644 index 9d69880..0000000 --- a/src/Controller/DeleteMediaObjectAction.php +++ /dev/null @@ -1,29 +0,0 @@ - - * @date 25.01.24 - */ - - -namespace App\Controller; - - -use App\Entity\MediaObject; -use Doctrine\ORM\EntityManagerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\HttpKernel\Attribute\AsController; - -#[AsController] -final class DeleteMediaObjectAction extends AbstractController -{ - - public function __invoke( - MediaObject $mediaObject, - EntityManagerInterface $em, - ): null - { - $em->remove($mediaObject); - $em->flush(); - return null; - } -} \ No newline at end of file diff --git a/src/Entity/Contact.php b/src/Entity/Contact.php index 1c3dc04..5df5f4f 100644 --- a/src/Entity/Contact.php +++ b/src/Entity/Contact.php @@ -7,6 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; #[ORM\Entity(repositoryClass: ContactRepository::class)] class Contact @@ -101,6 +102,11 @@ class Contact return $this->birthday; } + public function getBirthdayAsString(): string | null + { + return $this->birthday?->format('Y-m-d'); + } + public function setBirthday(?\DateTimeInterface $birthday): static { $this->birthday = $birthday; diff --git a/src/Entity/MediaObject.php b/src/Entity/MediaObject.php index 6075d64..ab750dc 100644 --- a/src/Entity/MediaObject.php +++ b/src/Entity/MediaObject.php @@ -15,7 +15,6 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Model; use App\Controller\CreateMediaObjectAction; -use App\Controller\DeleteMediaObjectAction; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\Serializer\Annotation\Groups; @@ -53,7 +52,7 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich; deserialize: false ), new Delete( - controller: DeleteMediaObjectAction::class + // controller: DeleteMediaObjectAction::class ), ], normalizationContext: ['groups' => ['media_object:read']] diff --git a/src/Mapper/ContactEntityToApiMapper.php b/src/Mapper/ContactEntityToApiMapper.php index b6ed827..64e6ae9 100644 --- a/src/Mapper/ContactEntityToApiMapper.php +++ b/src/Mapper/ContactEntityToApiMapper.php @@ -47,7 +47,7 @@ class ContactEntityToApiMapper implements MapperInterface MicroMapperInterface::MAX_DEPTH => 1, ] ); - $dto->birthday = $entity->getBirthday(); + $dto->birthday = $entity->getBirthdayAsString(); $dto->image = $entity->getImage(); $dto->imageUrl = $this->fileUrlService->getFileUrl($entity->getImage()); $dto->position = $entity->getPosition();