mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add a debug feature in docgenerator template controller
This commit is contained in:
parent
d907f3f11b
commit
531f940b65
@ -28,6 +28,7 @@ use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@ -211,14 +212,14 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
$builder = $this->createFormBuilder(
|
||||
array_merge(
|
||||
$context->getFormData($template, $entity),
|
||||
$isTest ? ['test_file' => null] : []
|
||||
$isTest ? ['test_file' => null, 'show_data' => false] : []
|
||||
)
|
||||
);
|
||||
|
||||
$context->buildPublicForm($builder, $template, $entity);
|
||||
} else {
|
||||
$builder = $this->createFormBuilder(
|
||||
['test_file' => null]
|
||||
['test_file' => null, 'show_data' => false]
|
||||
);
|
||||
}
|
||||
|
||||
@ -227,6 +228,10 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
'label' => 'Template file',
|
||||
'required' => false,
|
||||
]);
|
||||
$builder->add('show_data', CheckboxType::class, [
|
||||
'label' => 'Show data instead of generating',
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
$form = $builder->getForm()->handleRequest($request);
|
||||
@ -278,6 +283,11 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
}
|
||||
$datas = $context->getData($template, $entity, $contextGenerationData);
|
||||
|
||||
if ($isTest && $form['show_data']->getData()) {
|
||||
// very ugly hack...
|
||||
dd($datas);
|
||||
}
|
||||
|
||||
try {
|
||||
$generatedResource = $this->driver->generateFromResource($templateResource, $template->getFile()->getType(), $datas, $template->getFile()->getFilename());
|
||||
} catch (TemplateException $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user