From 29d7d0394097b2c2f25c681c74db081460ba84f4 Mon Sep 17 00:00:00 2001 From: gv Date: Tue, 21 Jul 2015 19:07:51 +0200 Subject: [PATCH] Passing custom parameters to registration template --- Controller/RegistrationManager.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Controller/RegistrationManager.php b/Controller/RegistrationManager.php index 0f98da2..fba7c94 100644 --- a/Controller/RegistrationManager.php +++ b/Controller/RegistrationManager.php @@ -57,24 +57,30 @@ public function __construct(UserDiscriminator $userDiscriminator, * @param string $class * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function register($class) + public function register($class, $vars = null) { $this->userDiscriminator->setClass($class); - + $this->controller->setContainer($this->container); - $result = $this->controller->registerAction($this->container->get('request')); + $result = $this->controller->registerAction($this->container->get('request')); if ($result instanceof RedirectResponse) { return $result; } - + $template = $this->userDiscriminator->getTemplate('registration'); if (is_null($template)) { $template = 'FOSUserBundle:Registration:register.html.twig'; } - - $form = $this->formFactory->createForm(); - return $this->container->get('templating')->renderResponse($template, array( - 'form' => $form->createView(), - )); + + $form = $this->formFactory->createForm(); + $variables = array ( + 'form' => $form->createView() + ); + + if (!empty($vars) && is_array($vars)) { + $variables = array_merge($variables, $vars); + } + + return $this->container->get('templating')->renderResponse($template, $variables); } }