mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
add form to doc generation and custom form to admin template configuration
This commit is contained in:
@@ -11,8 +11,55 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Controller;
|
||||
|
||||
use Chill\DocGeneratorBundle\Context\ContextManager;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class AdminDocGeneratorTemplateController extends CRUDController
|
||||
{
|
||||
private ContextManager $contextManager;
|
||||
|
||||
public function __construct(ContextManager $contextManager)
|
||||
{
|
||||
$this->contextManager = $contextManager;
|
||||
}
|
||||
|
||||
public function new(Request $request): Response
|
||||
{
|
||||
if (!$request->query->has('context')) {
|
||||
return $this->redirectToRoute("chill_docgen_admin_template_pick-context");
|
||||
}
|
||||
|
||||
return parent::new($request);
|
||||
}
|
||||
|
||||
protected function createEntity(string $action, Request $request): object
|
||||
{
|
||||
/** @var DocGeneratorTemplate $entity */
|
||||
$entity = parent::createEntity($action, $request);
|
||||
$key = $request->query->get('context');
|
||||
$context = $this->contextManager->getContextByKey($key);
|
||||
|
||||
$entity->setContext($key)->setEntity($context->getEntityClass());
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("{_locale}/admin/docgen/template/pick-context", name="chill_docgen_admin_template_pick-context")
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function pickContext(Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||
|
||||
return $this->render('ChillDocGeneratorBundle:Admin/DocGeneratorTemplate:pick-context.html.twig', [
|
||||
'contexts' => $this->contextManager->getContexts()
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user