4d3879156d
API Platform pagine par défaut à 30 éléments/page et le helper front extractHydraMembers ne lit que la première page (il ignore hydra:view.next), ce qui tronque silencieusement toute liste de plus de 30 éléments. - Back : paginationEnabled false sur les GetCollection consommées en entier et à volume borné/modéré (Client, Project, User, TaskTag, TaskGroup, TaskStatus, TaskPriority, TaskEffort, Workflow). - Front : nouveau helper fetchAllHydra() qui parcourt toutes les pages ; utilisé pour /notifications (volume non borné, reste paginé côté back). - Doc : règle anti-troncature ajoutée au CLAUDE.md. Déjà protégés (vérifiés) : Task, TimeEntry, TaskDocument, TaskRecurrence, AbsenceRequest/Policy/Balance (paginationEnabled false) et /time_entries/range.
132 lines
3.5 KiB
PHP
132 lines
3.5 KiB
PHP
<?php
|
|
|
|
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 App\Repository\WorkflowRepository;
|
|
use App\State\WorkflowDeleteProcessor;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
#[ApiResource(
|
|
operations: [
|
|
new GetCollection(paginationEnabled: false, 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')", processor: WorkflowDeleteProcessor::class),
|
|
],
|
|
normalizationContext: ['groups' => ['workflow:read']],
|
|
denormalizationContext: ['groups' => ['workflow:write']],
|
|
order: ['position' => 'ASC'],
|
|
)]
|
|
#[ORM\Entity(repositoryClass: WorkflowRepository::class)]
|
|
#[UniqueEntity(fields: ['name'], message: 'Ce nom de workflow est déjà utilisé.')]
|
|
class Workflow
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
#[Groups(['workflow:read', 'project:read', 'task_status:read'])]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255, unique: true)]
|
|
#[Groups(['workflow:read', 'workflow:write', 'project:read'])]
|
|
#[Assert\NotBlank]
|
|
private ?string $name = null;
|
|
|
|
#[ORM\Column(type: 'boolean', options: ['default' => false])]
|
|
#[Groups(['workflow:read', 'workflow:write'])]
|
|
private bool $isDefault = false;
|
|
|
|
#[ORM\Column(type: 'integer', options: ['default' => 0])]
|
|
#[Groups(['workflow:read', 'workflow:write'])]
|
|
private int $position = 0;
|
|
|
|
/** @var Collection<int, TaskStatus> */
|
|
#[ORM\OneToMany(targetEntity: TaskStatus::class, mappedBy: 'workflow', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
|
#[ORM\OrderBy(['position' => 'ASC'])]
|
|
#[Groups(['workflow:read', 'project:read'])]
|
|
private Collection $statuses;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->statuses = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isDefault(): bool
|
|
{
|
|
return $this->isDefault;
|
|
}
|
|
|
|
public function setIsDefault(bool $isDefault): static
|
|
{
|
|
$this->isDefault = $isDefault;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPosition(): int
|
|
{
|
|
return $this->position;
|
|
}
|
|
|
|
public function setPosition(int $position): static
|
|
{
|
|
$this->position = $position;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/** @return Collection<int, TaskStatus> */
|
|
public function getStatuses(): Collection
|
|
{
|
|
return $this->statuses;
|
|
}
|
|
|
|
public function addStatus(TaskStatus $status): static
|
|
{
|
|
if (!$this->statuses->contains($status)) {
|
|
$this->statuses->add($status);
|
|
$status->setWorkflow($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeStatus(TaskStatus $status): static
|
|
{
|
|
$this->statuses->removeElement($status);
|
|
|
|
return $this;
|
|
}
|
|
}
|