Skip to content

Commit

Permalink
fixed callback transformers types
Browse files Browse the repository at this point in the history
  • Loading branch information
lemorragia committed Aug 23, 2024
1 parent 01da961 commit bfea0db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Block/GalleryBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ private function getGalleryBuilder(AdminFormMapper $form): FormBuilderInterface
]);

$formBuilder->addModelTransformer(new CallbackTransformer(
static fn (?MediaInterface $value): ?MediaInterface => $value,
static fn (?MediaInterface $value) => $value instanceof MediaInterface ? $value->getId() : $value
static fn (?GalleryInterface $value): ?GalleryInterface => $value,
static fn (?GalleryInterface $value) => $value instanceof GalleryInterface ? $value->getId() : $value
));

return $formBuilder;
Expand Down
5 changes: 2 additions & 3 deletions src/Block/MediaBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\Form\Type\ImmutableArrayType;
use Sonata\Form\Validator\ErrorElement;
use Sonata\MediaBundle\Model\GalleryInterface;
use Sonata\MediaBundle\Model\MediaInterface;
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\Pool;
Expand Down Expand Up @@ -224,8 +223,8 @@ private function getMediaBuilder(AdminFormMapper $form): FormBuilderInterface
]);

$formBuilder->addModelTransformer(new CallbackTransformer(
static fn (?GalleryInterface $value): ?GalleryInterface => $value,
static fn (?GalleryInterface $value) => $value instanceof GalleryInterface ? $value->getId() : $value
static fn (?MediaInterface $value): ?MediaInterface => $value,
static fn (?MediaInterface $value) => $value instanceof MediaInterface ? $value->getId() : $value
));

return $formBuilder;
Expand Down

0 comments on commit bfea0db

Please sign in to comment.