mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-01-14 21:31:23 +00:00
Add attachments to workflow
This commit is contained in:
@@ -16,9 +16,18 @@ use Chill\MainBundle\Entity\UserGroup;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* A step for each EntityWorkflow.
|
||||
*
|
||||
* The step contains the history of position. The current one is the one which transitionAt or transitionAfter is NULL.
|
||||
*
|
||||
* The comments field is populated by the comment of the one who apply the transition, it means that the comment for the
|
||||
* "next" step is stored in the EntityWorkflowStep in the previous step.
|
||||
*
|
||||
* DestUsers are the one added at the transition. DestUserByAccessKey are the users who obtained permission after having
|
||||
* clicked on a link to get access (email notification to groups).
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table('chill_main_workflow_entity_step')]
|
||||
class EntityWorkflowStep
|
||||
@@ -80,6 +89,11 @@ class EntityWorkflowStep
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* If this is the final step.
|
||||
*
|
||||
* This property is filled by a listener.
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $isFinal = false;
|
||||
|
||||
@@ -254,6 +268,11 @@ class EntityWorkflowStep
|
||||
return $this->ccUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the comment from the one who apply the transition.
|
||||
*
|
||||
* It means that it must be saved when the user apply a transition.
|
||||
*/
|
||||
public function getComment(): string
|
||||
{
|
||||
return $this->comment;
|
||||
@@ -346,6 +365,9 @@ class EntityWorkflowStep
|
||||
return $this->transitionByEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool true if this is the end of the EntityWorkflow
|
||||
*/
|
||||
public function isFinal(): bool
|
||||
{
|
||||
return $this->isFinal;
|
||||
@@ -367,6 +389,9 @@ class EntityWorkflowStep
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool if the EntityWorkflowStep is waiting for a transition, and is not the final step
|
||||
*/
|
||||
public function isWaitingForTransition(): bool
|
||||
{
|
||||
if (null !== $this->transitionAfter) {
|
||||
@@ -506,26 +531,6 @@ class EntityWorkflowStep
|
||||
return $this->holdsOnStep;
|
||||
}
|
||||
|
||||
#[Assert\Callback]
|
||||
public function validateOnCreation(ExecutionContextInterface $context, mixed $payload): void
|
||||
{
|
||||
return;
|
||||
|
||||
if ($this->isFinalizeAfter()) {
|
||||
if (0 !== \count($this->getDestUser())) {
|
||||
$context->buildViolation('workflow.No dest users when the workflow is finalized')
|
||||
->atPath('finalizeAfter')
|
||||
->addViolation();
|
||||
}
|
||||
} else {
|
||||
if (0 === \count($this->getDestUser())) {
|
||||
$context->buildViolation('workflow.The next step must count at least one dest')
|
||||
->atPath('finalizeAfter')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addOnHold(EntityWorkflowStepHold $onHold): self
|
||||
{
|
||||
if (!$this->holdsOnStep->contains($onHold)) {
|
||||
|
||||
Reference in New Issue
Block a user