diff --git a/src/App/Entity/Team.php b/src/App/Entity/Team.php index 40e76fc..b9527e7 100755 --- a/src/App/Entity/Team.php +++ b/src/App/Entity/Team.php @@ -63,6 +63,24 @@ class Team implements JsonSerializable */ private $filterId; + /** + * @ORM\Column(name="daily_lock_enabled", type="boolean", options={"default" = false}) + * @var bool + */ + private $dailyLockEnabled = false; + + /** + * @ORM\Column(name="daily_start_time", type="time_immutable", nullable=true) + * @var \DateTimeImmutable + */ + private $dailyStartTime; + + /** + * @ORM\Column(name="daily_end_time", type="time_immutable", nullable=true) + * @var \DateTimeImmutable + */ + private $dailyEndTime; + /** * @ORM\Column(name="backlog_column", type="json", nullable=true) * @var KanbanColumn @@ -91,7 +109,7 @@ class Team implements JsonSerializable * @ORM\Column(name="is_active", type="boolean") * @var bool */ - private $isActive; + private $isActive = true; /** * @ORM\Column(name="created_at", type="datetime_immutable", nullable=true) @@ -243,6 +261,60 @@ class Team implements JsonSerializable return $this; } + /** + * @return bool + */ + public function isDailyLockEnabled(): bool + { + return $this->dailyLockEnabled; + } + + /** + * @param bool $dailyLockEnabled + * @return Team + */ + public function setDailyLockEnabled(bool $dailyLockEnabled): Team + { + $this->dailyLockEnabled = $dailyLockEnabled; + return $this; + } + + /** + * @return \DateTimeImmutable + */ + public function getDailyStartTime(): ?\DateTimeImmutable + { + return $this->dailyStartTime; + } + + /** + * @param \DateTimeInterface $dailyStartTime + * @return Team + */ + public function setDailyStartTime(?\DateTimeInterface $dailyStartTime): Team + { + $this->dailyStartTime = $dailyStartTime; + return $this; + } + + /** + * @return \DateTimeImmutable + */ + public function getDailyEndTime(): ?\DateTimeImmutable + { + return $this->dailyEndTime; + } + + /** + * @param \DateTimeInterface $dailyEndTime + * @return Team + */ + public function setDailyEndTime(?\DateTimeInterface $dailyEndTime): Team + { + $this->dailyEndTime = $dailyEndTime; + return $this; + } + /** * @return array|KanbanColumn */ @@ -380,6 +452,13 @@ class Team implements JsonSerializable 'members' => $this->getMembers() ?? [], 'labels' => $this->getLabels() ?? [], 'filterId' => $this->getFilterId(), + 'dailyLockEnabled' => $this->isDailyLockEnabled(), + 'dailyStartTime' => $this->getDailyStartTime() + ? $this->getDailyStartTime()->format("H:i") + : null, + 'dailyEndTime' => $this->getDailyEndTime() + ? $this->getDailyEndTime()->format("H:i") + : null, 'backlogColumn' => $this->getBacklogColumn() ?? new KanbanColumn(), 'inprogressColumn' => $this->getInprogressColumn() ?? new KanbanColumn(), 'verificationColumn' => $this->getVerificationColumn() ?? new KanbanColumn(), diff --git a/src/App/Form/Team.php b/src/App/Form/Team.php index 9b50c3f..d4d1437 100755 --- a/src/App/Form/Team.php +++ b/src/App/Form/Team.php @@ -63,6 +63,42 @@ class Team */ private $filterId; + /** + * Also a dummy field, a + * @Annotation\Type("Zend\Form\Element\Text") + * @Annotation\Options({ + * "label": "Enabled" + * }) + * @Annotation\Validator({ + * "name":"NotEmpty", + * "options": {"type": Zend\Validator\NotEmpty::NULL} + * }) + * @Annotation\Required(false) + + * @var bool + */ + private $dailyLockEnabled; + + /** + * @Annotation\Type("Zend\Form\Element\Text") + * @Annotation\Required(false) + * @Annotation\Options({ + * "label": "Start time" + * }) + * @var array + */ + private $dailyStartTime; + + /** + * @Annotation\Type("Zend\Form\Element\Text") + * @Annotation\Required(false) + * @Annotation\Options({ + * "label": "End time" + * }) + * @var array + */ + private $dailyEndTime; + /** * This is a dummy field, not a text actually. Only used to filter the input * @Annotation\Type("Zend\Form\Element\Text") diff --git a/src/DoctrineExpressiveModule/Hydrator/DoctrineObject.php b/src/DoctrineExpressiveModule/Hydrator/DoctrineObject.php old mode 100644 new mode 100755 index 95445e6..9b9a7b9 --- a/src/DoctrineExpressiveModule/Hydrator/DoctrineObject.php +++ b/src/DoctrineExpressiveModule/Hydrator/DoctrineObject.php @@ -20,6 +20,7 @@ namespace DoctrineExpressiveModule\Hydrator; use DateTime; +use DateTimeImmutable; use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Util\Inflector; @@ -484,9 +485,10 @@ class DoctrineObject extends AbstractHydrator /** * Handle various type conversions that should be supported natively by Doctrine (like DateTime) * - * @param mixed $value + * @param mixed $value * @param string $typeOfField - * @return DateTime + * @return DateTime|DateTimeImmutable + * @throws \Exception */ protected function handleTypeConversions($value, $typeOfField) { @@ -507,6 +509,23 @@ class DoctrineObject extends AbstractHydrator $value = new DateTime($value); } + break; + case 'datetimetz_immutable': + case 'datetime_immutable': + case 'time_immutable': + case 'date_immutable': + if ('' === $value) { + return null; + } + + if (is_int($value)) { + $dateTime = new DateTimeImmutable(); + $dateTime->setTimestamp($value); + $value = $dateTime; + } elseif (is_string($value)) { + $value = new DateTimeImmutable($value); + } + break; default: }