Add attachments to workflow

This commit is contained in:
2025-02-03 21:15:00 +00:00
parent 9e191f1b5b
commit 37227a3aeb
106 changed files with 3455 additions and 619 deletions

View File

@@ -0,0 +1,42 @@
<?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\Workflow\Attachment;
use Chill\DocStoreBundle\GenericDoc\Exception\AssociatedStoredObjectNotFound;
use Chill\DocStoreBundle\GenericDoc\ManagerInterface;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowAttachment;
use Doctrine\ORM\EntityManagerInterface;
class AddAttachmentAction
{
public function __construct(private readonly EntityManagerInterface $em, private readonly ManagerInterface $manager) {}
/**
* @throws AssociatedStoredObjectNotFound
*/
public function __invoke(AddAttachmentRequestDTO $dto): EntityWorkflowAttachment
{
$genericDoc = $this->manager->buildOneGenericDoc($dto->relatedGenericDocKey, $dto->relatedGenericDocIdentifiers);
if (null === $genericDoc) {
throw new \RuntimeException(sprintf('could not build any generic doc, %s key and %s identifiers', $dto->relatedGenericDocKey, json_encode($dto->relatedGenericDocIdentifiers)));
}
$storedObject = $this->manager->fetchStoredObject($genericDoc);
$attachement = new EntityWorkflowAttachment($dto->relatedGenericDocKey, $dto->relatedGenericDocIdentifiers, $dto->entityWorkflow, $storedObject);
$this->em->persist($attachement);
return $attachement;
}
}

View File

@@ -0,0 +1,30 @@
<?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\Workflow\Attachment;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
final class AddAttachmentRequestDTO
{
#[Serializer\Groups('write')]
#[Assert\NotNull()]
public ?string $relatedGenericDocKey = null;
#[Serializer\Groups('write')]
#[Assert\NotNull()]
public ?array $relatedGenericDocIdentifiers = null;
public function __construct(
public readonly EntityWorkflow $entityWorkflow,
) {}
}