add content-type field in node

This commit is contained in:
Simon Vieille 2021-05-20 19:56:07 +02:00
parent bc6d5e5e88
commit 87c15f3b1f
5 changed files with 42 additions and 0 deletions

View file

@ -31,6 +31,14 @@ class PageController extends AbstractController
{
$parameters = array_merge($this->getDefaultRenderParameters(), $parameters);
if ($response === null) {
$contentType = $this->siteRequest->getNode()->getContentType();
$response = new Response(null, 200, [
'Content-Type' => $contentType ?? 'text/html',
]);
}
return parent::render($view, $parameters, $response);
}

View file

@ -133,6 +133,11 @@ class Node implements EntityInterface
*/
protected $aliasNodes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contentType;
public function __construct()
{
$this->children = new ArrayCollection();
@ -491,4 +496,16 @@ class Node implements EntityInterface
return $this;
}
public function getContentType(): ?string
{
return $this->contentType;
}
public function setContentType(?string $contentType): self
{
$this->contentType = $contentType;
return $this;
}
}

View file

@ -73,6 +73,20 @@ class NodeType extends AbstractType
]
);
$builder->add(
'contentType',
TextType::class,
[
'label' => 'Content type',
'required' => false,
'help' => 'Leave blank equals "text/html"',
'attr' => [
],
'constraints' => [
],
]
);
$builder->add(
'controller',
TextType::class,

View file

@ -151,3 +151,5 @@
"Force this domain": "Forcer ce nom de domaine"
"Additional domains": "Domaines additionnels"
"Regular expression: do not add the delimiter": "Expréssion régulière : ne pas ajouter de délimiteur"
"Content type": "Type de contenu"
'Leave blank equals "text/html"': 'Laissez vide équivaut à "text/html"'

View file

@ -176,6 +176,7 @@
{{ form_row(form.disableUrl) }}
{{ form_row(form.code) }}
{{ form_row(form.contentType) }}
{{ form_row(form.controller) }}
<div class="accordion mb-3" data-collection="collection-node-parameters" id="form-node-edit-parameters-collection">