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