mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
Generate a context for docgen, on accompanying period
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Controller;
|
||||
|
||||
use Base64Url\Base64Url;
|
||||
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface;
|
||||
use Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
@@ -19,23 +20,19 @@ use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use PhpOffice\PhpWord\TemplateProcessor;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlOpenstackGenerator;
|
||||
use Jose\Component\Core\JWK;
|
||||
use Base64Url\Base64Url;
|
||||
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
// TODO à mettre dans services
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
|
||||
@@ -43,13 +40,13 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
final class DocGeneratorTemplateController extends AbstractController
|
||||
{
|
||||
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
|
||||
private HttpClientInterface $client;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
|
||||
|
||||
private KernelInterface $kernel;
|
||||
|
||||
private HttpClientInterface $client;
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
public function __construct(
|
||||
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
||||
@@ -78,7 +75,8 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
): Response {
|
||||
$getUrlGen = $tempUrlGenerator->generate(
|
||||
'GET',
|
||||
$template->getFile()->getFilename());
|
||||
$template->getFile()->getFilename()
|
||||
);
|
||||
|
||||
$data = $this->client->request('GET', $getUrlGen->url);
|
||||
|
||||
@@ -92,23 +90,25 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
|
||||
$dataDecrypted = openssl_decrypt($data->getContent(), $method, $keyGoodFormat, 1, $ivGoodFormat);
|
||||
|
||||
if ($dataDecrypted === FALSE) {
|
||||
throw new \Exception("Error during Decrypt ", 1);
|
||||
if (false === $dataDecrypted) {
|
||||
throw new \Exception('Error during Decrypt ', 1);
|
||||
}
|
||||
|
||||
$tmpfnameDeCrypted = tempnam($this->kernel->getCacheDir(), 'DECRYPT_DOC_TEMPLATE'); // plus ou moins
|
||||
|
||||
if (!$handle = fopen($tmpfnameDeCrypted, 'a')) {
|
||||
echo "Cannot open file ($tmpfnameDeCrypted)";
|
||||
if (!$handle = fopen($tmpfnameDeCrypted, 'ab')) {
|
||||
echo "Cannot open file ({$tmpfnameDeCrypted})";
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if (fwrite($handle, $dataDecrypted) === FALSE) {
|
||||
echo "Cannot write to file ($tmpfnameDeCrypted)";
|
||||
if (fwrite($handle, $dataDecrypted) === false) {
|
||||
echo "Cannot write to file ({$tmpfnameDeCrypted})";
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
dump("Success, wrote ($dataDecrypted) to file ($tmpfnameDeCrypted)");
|
||||
dump("Success, wrote ({$dataDecrypted}) to file ({$tmpfnameDeCrypted})");
|
||||
|
||||
fclose($handle);
|
||||
|
||||
@@ -185,7 +185,7 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
}
|
||||
|
||||
throw new Exception('Unable to generate document.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
|
Reference in New Issue
Block a user