FEATURE [absence][in_progress] add absence property to user, create form, controller, template, migration and menu entry

This commit is contained in:
2023-01-11 17:16:37 +01:00
parent 99455ca685
commit fb51e44e45
7 changed files with 159 additions and 1 deletions

View File

@@ -11,14 +11,15 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use RuntimeException;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function in_array;
/**
@@ -40,6 +41,11 @@ class User implements AdvancedUserInterface
*/
protected ?int $id = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTimeImmutable $absenceStart = null;
/**
* Array where SAML attributes's data are stored.
*
@@ -175,6 +181,11 @@ class User implements AdvancedUserInterface
{
}
public function getAbsenceStart(): ?DateTimeImmutable
{
return $this->absenceStart;
}
/**
* Get attributes.
*
@@ -295,6 +306,11 @@ class User implements AdvancedUserInterface
return $this->usernameCanonical;
}
public function isAbsent(): bool
{
return null !== $this->getAbsenceStart() ? true : false;
}
/**
* @return bool
*/
@@ -359,6 +375,11 @@ class User implements AdvancedUserInterface
}
}
public function setAbsenceStart(?DateTimeImmutable $absenceStart): void
{
$this->absenceStart = $absenceStart;
}
public function setAttributeByDomain(string $domain, string $key, $value): self
{
$this->attributes[$domain][$key] = $value;