+ /**
+ * {@inheritdoc}
+ *
+ * Renders a view
+ */
+ protected function render(string $view, array $parameters = [], Response $response = null): Response {
+ //Create response when null
+ $response ??= new Response();
+
+ //With empty head locale
+ if (empty($parameters['locale'])) {
+ //Set head locale
+ $parameters['locale'] = $this->locale;
+ }
+
+ //Call twig render method
+ $content = $this->twig->render($view, $parameters);
+
+ //Invalidate OK response on invalid form
+ if (200 === $response->getStatusCode()) {
+ foreach ($parameters as $v) {
+ if ($v instanceof FormInterface && $v->isSubmitted() && !$v->isValid()) {
+ $response->setStatusCode(422);
+ break;
+ }
+ }
+ }
+
+ //Store content in response
+ $response->setContent($content);
+
+ //Return response
+ return $response;
+ }
+