瀏覽代碼

fix Access::setHistorical

Olivier Massot 2 年之前
父節點
當前提交
9d424b07e2
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/Entity/Access/Access.php

+ 6 - 1
src/Entity/Access/Access.php

@@ -422,9 +422,14 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
     #[Groups(['my_access:input'])]
     public function setHistorical(array $historical): self
     {
-        if (!$historical['past'] && !$historical['present'] && !$historical['future']) {
+        if (($historical['dateStart'] && !$historical['dateEnd']) || (!$historical['dateStart'] && $historical['dateEnd'])) {
+            $historical['dateStart'] = null;
+            $historical['dateEnd'] = null;
+        }
+        if (!$historical['past'] && !$historical['present'] && !$historical['future'] && !$historical['dateStart'] ) {
             $historical['present'] = true;
         }
+
         $this->setting['historical'] = $historical;
         return $this;
     }