php - Dynamically Styling an FOS UserBundle Login Page -



php - Dynamically Styling an FOS UserBundle Login Page -

i relatively new symfony 2 have site many different sub domains , user areas login page styled differently, not. using symfony 2 , fos userbundle , working 1 firewall in security.yml. overriding fos userbundle layout per documentation, able style page differently depending on request coming from, example: microsite1.mainsite.com/user gets style microsite1.mainsite.com/admin gets style b microsite2.mainsite.come/user gets style c

i have considered few options , i'm looking other opinions. first alternative had considered overriding/extending controllers in fos userbundle referrer identified , different twig template rendered. alternative utilize different firewall different routes, want able have users in different microsites authenticated across sites 1 firewall preferred. there other solutions this, or there 1 way more preferable tackle relatively minor issue?

you can override renderlogin method of securitycontroller. here how it:

class="lang-php prettyprint-override">namespace acme\userbundle\controller; utilize fos\userbundle\controller\securitycontroller basecontroller; utilize symfony\component\dependencyinjection\containeraware; utilize symfony\component\security\core\securitycontext; utilize symfony\component\httpfoundation\request; class securitycontroller extends basecontroller { /** * overriding fos default method can take template */ protected function renderlogin(array $data) { $template = $this->gettemplate(); homecoming $this->container->get('templating')->renderresponse($template, $data); } /** * subdomain , homecoming right template */ public function gettemplate(){ $subdomain = $this->container->get('request')->gethost(); if ($subdomain === "microsite1.mainsite.com"){ $template = sprintf('acmeuserbundle:security:loginmicrosite1.html.%s', $this->container->getparameter('fos_user.template.engine')); } elseif($subdomain === "microsite2.mainsite.com"){ $template = sprintf('acmeuserbundle:security:loginmicrosite2.html.%s', $this->container->getparameter('fos_user.template.engine')); } //blablabla //customize need here. homecoming $template; }

php symfony2 fosuserbundle

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -