getDocumentFilename example

protected function assignDocuments(Log $logEntry, Enlight_Components_Mail $mail): void
    {
        if (!$mail->hasAttachments || $logEntry->getOrder() === null) {
            return;
        }

        $documents = $this->entityManager->getRepository(Order::class)->getDocuments([$logEntry->getOrder()->getId()]);
        $filenameIdMap = [];

        foreach ($documents as $document) {
            $filename = $this->getDocumentFilename($document);

            if ($filename) {
                $filenameIdMap[$filename] = $document['id'];
            }
        }

        foreach ($mail->getParts() as $part) {
            if (isset($filenameIdMap[$part->filename])) {
                $document = $this->entityManager->getPartialReference(
                    Document::class,
                    $filenameIdMap[$part->filename]
                );
Home | Imprint | This part of the site doesn't use cookies.