mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 04:56:13 +00:00
Created new files to add signature functionality to the workflow entities, including signature state enums and signature metadata. Added these changes to the migration script as well. Updated EntityWorkflowStep to include a collection for signatures.
157 lines
4.2 KiB
PHP
157 lines
4.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Entity\Workflow;
|
|
|
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity]
|
|
#[ORM\Table(name: 'chill_main_workflow_entity_step_signature')]
|
|
class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdateInterface
|
|
{
|
|
use TrackCreationTrait;
|
|
use TrackUpdateTrait;
|
|
|
|
#[ORM\Id]
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, unique: true)]
|
|
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: User::class)]
|
|
#[ORM\JoinColumn(nullable: true)]
|
|
private ?User $userSigner = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Person::class)]
|
|
#[ORM\JoinColumn(nullable: true)]
|
|
private ?Person $personSigner = null;
|
|
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 50, nullable: false, enumType: EntityWorkflowSignatureStateEnum::class)]
|
|
private EntityWorkflowSignatureStateEnum $state = EntityWorkflowSignatureStateEnum::PENDING;
|
|
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIMETZ_IMMUTABLE, nullable: true, options: ['default' => null])]
|
|
private ?\DateTimeImmutable $stateDate = null;
|
|
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]'])]
|
|
private array $signatureMetadata = [];
|
|
|
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])]
|
|
private ?int $zoneSignatureIndex = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: EntityWorkflowStep::class, inversedBy: 'signatures')]
|
|
#[ORM\JoinColumn(nullable: false)]
|
|
private ?EntityWorkflowStep $step = null;
|
|
|
|
public function __construct(
|
|
EntityWorkflowStep $step,
|
|
User|Person $signer,
|
|
) {
|
|
$this->step = $step;
|
|
$step->addSignature($this);
|
|
$this->setSigner($signer);
|
|
}
|
|
|
|
private function setSigner(User|Person $signer): void
|
|
{
|
|
if ($signer instanceof User) {
|
|
$this->userSigner = $signer;
|
|
} else {
|
|
$this->personSigner = $signer;
|
|
}
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getStep(): EntityWorkflowStep
|
|
{
|
|
return $this->step;
|
|
}
|
|
|
|
public function getSigner(): User|Person
|
|
{
|
|
if (null !== $this->userSigner) {
|
|
return $this->userSigner;
|
|
}
|
|
|
|
return $this->personSigner;
|
|
}
|
|
|
|
public function getSignatureMetadata(): array
|
|
{
|
|
return $this->signatureMetadata;
|
|
}
|
|
|
|
public function setSignatureMetadata(array $signatureMetadata): EntityWorkflowStepSignature
|
|
{
|
|
$this->signatureMetadata = $signatureMetadata;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getState(): EntityWorkflowSignatureStateEnum
|
|
{
|
|
return $this->state;
|
|
}
|
|
|
|
public function setState(EntityWorkflowSignatureStateEnum $state): EntityWorkflowStepSignature
|
|
{
|
|
$this->state = $state;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStateDate(): ?\DateTimeImmutable
|
|
{
|
|
return $this->stateDate;
|
|
}
|
|
|
|
public function setStateDate(?\DateTimeImmutable $stateDate): EntityWorkflowStepSignature
|
|
{
|
|
$this->stateDate = $stateDate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getZoneSignatureIndex(): ?int
|
|
{
|
|
return $this->zoneSignatureIndex;
|
|
}
|
|
|
|
public function setZoneSignatureIndex(?int $zoneSignatureIndex): EntityWorkflowStepSignature
|
|
{
|
|
$this->zoneSignatureIndex = $zoneSignatureIndex;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Detach from the @see{EntityWorkflowStep}.
|
|
*
|
|
* @internal used internally to remove the current signature
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function detachEntityWorkflowStep(): self
|
|
{
|
|
$this->step = null;
|
|
|
|
return $this;
|
|
}
|
|
}
|