Skip to content

Commit

Permalink
correction et config unoserver
Browse files Browse the repository at this point in the history
  • Loading branch information
sebheitzmann committed Apr 1, 2024
1 parent 3950c57 commit a0e6b78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
17 changes: 6 additions & 11 deletions src/Controller/PdfGenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Lle\PdfGeneratorBundle\Generator\PdfGenerator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -22,7 +23,7 @@ class PdfGenController extends AbstractController
{
public function __construct(
private EntityManagerInterface $em,
private PdfGenerator $pdfGenerator
private PdfGenerator $pdfGenerator,
) {
}

Expand Down Expand Up @@ -89,16 +90,10 @@ public function checkModele(Request $request): RedirectResponse
}

#[Route("/balises", name: "lle_pdf_generator_admin_balise")]
public function balise(): Response
{
$configDatas = Yaml::parseFile(__DIR__ . '/../../../../../config/packages/pdf_generator.yaml');

if (array_key_exists('data_models', $configDatas['lle_pdf_generator'])) {
$models = $configDatas['lle_pdf_generator']['data_models'];
} else {
$models = [0 => 'pdfgenerator'];
}

public function balise(
ParameterBagInterface $parameterBag,
): Response {
$models = $parameterBag->get('lle.pdf.data_models');
return $this->render('@LlePdfGenerator/balise/index.html.twig', [
'models' => $models,
]);
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$nodeBuilder->scalarNode('default_generator')->defaultValue('word_to_pdf')->end();
$nodeBuilder->scalarNode('path')->defaultValue('data/pdfmodel')->end();
$nodeBuilder->scalarNode('class')->defaultValue(PdfModel::class)->end();
$nodeBuilder->scalarNode('unoserver')->defaultValue('http://unoserver/convert')->end();
$nodeBuilder->arrayNode('data_models')->scalarPrototype()->end();

return $treeBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/WordToPdfGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function wordToPdf(string $source, iterable $params, string $savePath, a
file_put_contents($tmpFile . '.html.twig', $template->render($params));
$tmpFile = $tmpFile . '.html.twig';
}*/
$rep = $this->httpClient->request("POST", "http://unoserver/convert", ['body' => file_get_contents($tmpFile)]);
$rep = $this->httpClient->request("POST", $this->parameterBag->get('lle.pdf.unoserver'), ['body' => file_get_contents($tmpFile)]);
file_put_contents($savePath, $rep->getContent());
}

Expand Down

0 comments on commit a0e6b78

Please sign in to comment.