fix : wip

This commit is contained in:
2026-02-19 17:44:37 +01:00
parent c2e118dc33
commit 13274ff297
31 changed files with 1539 additions and 126 deletions

View File

@@ -9,12 +9,39 @@ use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use App\Enum\HalfDay;
use App\Repository\AbsenceRepository;
use App\State\AbsenceWriteProcessor;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ApiResource(
operations: [
new GetCollection(
security: "is_granted('ROLE_USER')"
),
new Get(
security: "is_granted('ABSENCE_VIEW', object)"
),
new Post(
securityPostDenormalize: "is_granted('ABSENCE_EDIT', object)",
processor: AbsenceWriteProcessor::class
),
new Patch(
security: "is_granted('ABSENCE_EDIT', object)",
processor: AbsenceWriteProcessor::class
),
new Delete(
security: "is_granted('ABSENCE_EDIT', object)",
processor: AbsenceWriteProcessor::class
),
],
normalizationContext: [
'groups' => ['absence:read', 'employee:read', 'absence_type:read'],
'datetime_format' => 'Y-m-d',
@@ -23,7 +50,6 @@ use Symfony\Component\Serializer\Attribute\Groups;
'datetime_format' => 'Y-m-d',
],
paginationEnabled: false,
security: "is_granted('ROLE_ADMIN')",
)]
#[ApiFilter(DateFilter::class, properties: ['startDate', 'endDate'])]
#[ApiFilter(SearchFilter::class, properties: ['employee.site' => 'exact'])]
@@ -53,17 +79,17 @@ class Absence
#[Groups(['absence:read'])]
private DateTimeInterface $startDate;
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'AM'])]
#[ORM\Column(type: 'string', length: 2, enumType: HalfDay::class, options: ['default' => 'AM'])]
#[Groups(['absence:read'])]
private string $startHalf = 'AM';
private HalfDay $startHalf = HalfDay::AM;
#[ORM\Column(type: 'date')]
#[Groups(['absence:read'])]
private DateTimeInterface $endDate;
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'PM'])]
#[ORM\Column(type: 'string', length: 2, enumType: HalfDay::class, options: ['default' => 'PM'])]
#[Groups(['absence:read'])]
private string $endHalf = 'PM';
private HalfDay $endHalf = HalfDay::PM;
#[ORM\Column(type: 'text', nullable: true)]
#[Groups(['absence:read'])]
@@ -122,24 +148,24 @@ class Absence
return $this;
}
public function getStartHalf(): string
public function getStartHalf(): HalfDay
{
return $this->startHalf;
}
public function setStartHalf(string $startHalf): self
public function setStartHalf(HalfDay $startHalf): self
{
$this->startHalf = $startHalf;
return $this;
}
public function getEndHalf(): string
public function getEndHalf(): HalfDay
{
return $this->endHalf;
}
public function setEndHalf(string $endHalf): self
public function setEndHalf(HalfDay $endHalf): self
{
$this->endHalf = $endHalf;

View File

@@ -5,13 +5,34 @@ declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ApiResource(
operations: [
new GetCollection(
security: "is_granted('ROLE_USER')"
),
new Get(
security: "is_granted('ROLE_USER')"
),
new Post(
security: "is_granted('ROLE_ADMIN')"
),
new Patch(
security: "is_granted('ROLE_ADMIN')"
),
new Delete(
security: "is_granted('ROLE_ADMIN')"
),
],
normalizationContext: ['groups' => ['absence_type:read']],
paginationEnabled: false,
security: "is_granted('ROLE_ADMIN')"
)]
#[ORM\Entity]
#[ORM\Table(name: 'absence_types')]
@@ -35,6 +56,10 @@ class AbsenceType
#[Groups(['absence:read', 'absence_type:read'])]
private string $color = '';
#[ORM\Column(type: 'boolean', options: ['default' => false])]
#[Groups(['absence:read', 'absence_type:read'])]
private bool $countAsWorkedHours = false;
public function getId(): ?int
{
return $this->id;
@@ -75,4 +100,21 @@ class AbsenceType
return $this;
}
public function isCountAsWorkedHours(): bool
{
return $this->countAsWorkedHours;
}
public function getCountAsWorkedHours(): bool
{
return $this->countAsWorkedHours;
}
public function setCountAsWorkedHours(bool $countAsWorkedHours): self
{
$this->countAsWorkedHours = $countAsWorkedHours;
return $this;
}
}