DocumentIdCollection example

'documentIds' => ArrayParameterType::STRING]
        );
    }

    /** * @param array<string, array<string, string|array<string, string>>> $documentTypes */
    private function createDocuments(string $orderId, array $documentTypes, Context $context): DocumentIdCollection
    {
        $operations = [];

        $collection = new DocumentIdCollection();

        foreach ($documentTypes as $documentType => $config) {
            $operation = new DocumentGenerateOperation($orderId, FileTypes::PDF, $config);
            $operations[$orderId] = $operation;

            $result = $this->documentGenerator->generate($documentType$operations$context)->getSuccess()->first();

            static::assertNotNull($result);
            $collection->add($result);
        }

        
'documentIds' => ArrayParameterType::STRING]
        );
    }

    /** * @param array<string, array<string, array<string, string>|string>> $documentTypes */
    private function createDocuments(string $orderId, array $documentTypes, Context $context): DocumentIdCollection
    {
        $operations = [];

        $collection = new DocumentIdCollection();

        foreach ($documentTypes as $documentType => $config) {
            $operation = new DocumentGenerateOperation($orderId, FileTypes::PDF, $config);
            $operations[$orderId] = $operation;

            $result = $this->documentGenerator->generate($documentType$operations$context);

            static::assertNotNull($document = $result->getSuccess()->first());
            $collection->add($document);
        }

        
class DocumentGenerationResult extends Struct
{
    private readonly DocumentIdCollection $success;

    /** * @var \Throwable[] */
    private array $errors = [];

    public function __construct()
    {
        $this->success = new DocumentIdCollection();
    }

    public function getSuccess(): DocumentIdCollection
    {
        return $this->success;
    }

    public function addSuccess(DocumentIdStruct $document): void
    {
        $this->success->add($document);
    }

    
Home | Imprint | This part of the site doesn't use cookies.