Skip to content

Commit

Permalink
Merge pull request #109 from clem/patch-1
Browse files Browse the repository at this point in the history
Add support of \DateTimeInterface in setContentFields
  • Loading branch information
nestordedios authored Nov 22, 2022
2 parents 460d2c6 + 2530493 commit 78c1047
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/EventSubscriber/ContentTypePersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Bolt\Entity\Content;
use Bolt\Enum\Statuses;
use Bolt\Repository\UserRepository;
use Carbon\Carbon;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Form;
Expand Down Expand Up @@ -90,6 +91,11 @@ private function setContentFields(Content $content, Form $form, PostSubmitEvent
return $entry[0];
}, $value));
}

if ($value instanceof \DateTimeInterface) {
$value = Carbon::createFromInterface($value);
}

$value = (string) $value;

if (in_array($name, array_keys($data['attachments'] ?? null), true)) {
Expand Down

0 comments on commit 78c1047

Please sign in to comment.