|
|
@@ -422,11 +422,28 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
#[Groups(['my_access:input'])]
|
|
|
public function setHistorical(array $historical): self
|
|
|
{
|
|
|
- if (($historical['dateStart'] && !$historical['dateEnd']) || (!$historical['dateStart'] && $historical['dateEnd'])) {
|
|
|
- $historical['dateStart'] = null;
|
|
|
- $historical['dateEnd'] = null;
|
|
|
+ // Une entrée dateStart mais pas de dateEnd, on retire dateEnd
|
|
|
+ if (array_key_exists('dateStart', $historical) && !array_key_exists('dateEnd', $historical)) {
|
|
|
+ unset($historical['dateStart']);
|
|
|
}
|
|
|
- if (!$historical['past'] && !$historical['present'] && !$historical['future'] && !$historical['dateStart'] ) {
|
|
|
+
|
|
|
+ // Une entrée dateEnd mais pas de dateStart, on retire dateEnd
|
|
|
+ if (!array_key_exists('dateStart', $historical) && array_key_exists('dateEnd', $historical)) {
|
|
|
+ unset($historical['dateEnd']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Les entrées dateStart et dateEnd existent mais ne sont pas toutes les deux renseignées, on retire les deux
|
|
|
+ if (
|
|
|
+ array_key_exists('dateStart', $historical) &&
|
|
|
+ array_key_exists('dateEnd', $historical) &&
|
|
|
+ (!$historical['dateStart'] || !$historical['dateEnd'])
|
|
|
+ ) {
|
|
|
+ unset($historical['dateStart']);
|
|
|
+ unset($historical['dateEnd']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Aucun temps ni période n'est défini, on définit par défaut present à vrai
|
|
|
+ if (!$historical['past'] && !$historical['present'] && !$historical['future'] && !array_key_exists('dateStart', $historical) ) {
|
|
|
$historical['present'] = true;
|
|
|
}
|
|
|
|