|
|
@@ -6,6 +6,7 @@ namespace App\Service\Export\Encoder;
|
|
|
|
|
|
use App\Enum\Export\ExportFormatEnum;
|
|
|
use Phpdocx\Create\CreateDocx;
|
|
|
+use Twig\Environment;
|
|
|
|
|
|
/**
|
|
|
* Encode HTML to docx format
|
|
|
@@ -13,6 +14,14 @@ use Phpdocx\Create\CreateDocx;
|
|
|
class DocXEncoder implements EncoderInterface
|
|
|
{
|
|
|
|
|
|
+ private Environment $twig;
|
|
|
+
|
|
|
+ public function __construct(Environment $twig)
|
|
|
+ {
|
|
|
+ $this->twig = $twig;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public function support(string $format): bool
|
|
|
{
|
|
|
return $format === ExportFormatEnum::DOCX()->getValue();
|
|
|
@@ -29,11 +38,11 @@ class DocXEncoder implements EncoderInterface
|
|
|
public function encode(string $html, array $options = []): string
|
|
|
{
|
|
|
$docx = new CreateDocx();
|
|
|
- $docx->addText($html);
|
|
|
+ $docx->embedHTML('<html><head></head></heade><body><p>Coucou</p></body></html>');
|
|
|
$tempFile = tempnam(sys_get_temp_dir(), 'docx');
|
|
|
$docx->createDocx($tempFile);
|
|
|
- $docxContent = file_get_contents($tempFile);
|
|
|
+ $content = file_get_contents($tempFile);
|
|
|
unlink($tempFile);
|
|
|
- return $docxContent;
|
|
|
+ return $content;
|
|
|
}
|
|
|
}
|