From fb43980a2a87dd390354a1e4a09452c32453adac Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 10 Aug 2021 10:56:45 +0200 Subject: [PATCH] everything changed to datetime --- .../src/Entity/AsideActivity.php | 18 +++++++++--------- .../src/Entity/AsideActivityCategory.php | 2 +- .../src/Form/AsideActivityFormType.php | 5 +++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index 0da691ff2..fda40ea1a 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -35,9 +35,9 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac private \Chill\MainBundle\Entity\User $createdBy; /** - * @ORM\Column(type="datetime_immutable") + * @ORM\Column(type="datetime") */ - private \DateTimeInterface $createdAt; + private $createdAt; /** * @ORM\ManyToOne(targetEntity=User::class) @@ -45,9 +45,9 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac private \Chill\MainBundle\Entity\User $updatedBy; /** - * @ORM\Column(type="datetime_immutable", nullable=true) + * @ORM\Column(type="datetime", nullable=true) */ - private \DateTimeInterface $updatedAt; + private $updatedAt; /** * @ORM\ManyToOne(targetEntity=User::class) @@ -57,14 +57,14 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac private \Chill\MainBundle\Entity\User $agent; /** - * @ORM\Column(type="datetime_immutable") + * @ORM\Column(type="datetime") */ - private \DateTimeInterface $date; + private $date; /** * @ORM\Column(type="time", nullable=true) */ - private ?\DateTime $duration = null; + private ?\DateTimeInterface $duration = null; /** * @ORM\Column(type="string", length=100, nullable=true) @@ -165,12 +165,12 @@ final class AsideActivity implements TrackUpdateInterface, TrackCreationInterfac return $this; } - public function getDuration(): ?\DateTime + public function getDuration(): ?\DateTimeInterface { return $this->duration; } - public function setDuration(?\DateTime $duration): self + public function setDuration(?\DateTimeInterface $duration): self { $this->duration = $duration; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php index ae22b4d7e..6c580394b 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivityCategory.php @@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity * @ORM\Table(schema="chill_asideactivity") */ -final class AsideActivityCategory +class AsideActivityCategory { /** * @ORM\Id diff --git a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php index b34e5bdf9..0ee91a9fe 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Form/AsideActivityFormType.php @@ -55,7 +55,7 @@ final class AsideActivityFormType extends AbstractType ->add('date', ChillDateType::class, [ 'label' => 'date', - 'data' => new \DateTimeImmutable(), + 'data' => new \DateTime(), //SETTING RANGE ONLY POSSIBLE WITH WIDGET 'CHOICE' AND NOT 'SINGLE_TEXT'? // 'widget' => 'choice', // 'years' => range(2020, date('Y')), @@ -96,13 +96,14 @@ final class AsideActivityFormType extends AbstractType // set the timezone to GMT, and fix the difference between current and GMT // the datetimetransformer will then handle timezone as GMT $timezoneUTC = new \DateTimeZone('GMT'); - /* @var $data \DateTime */ + /* @var $data \DateTimeImmutable */ $data = $formEvent->getData() === NULL ? \DateTime::createFromFormat('U', 300) : $formEvent->getData(); $seconds = $data->getTimezone()->getOffset($data); $data->setTimeZone($timezoneUTC); $data->add(new \DateInterval('PT'.$seconds.'S')); + dump($data); // test if the timestamp is in the choices. // If not, recreate the field with the new timestamp