These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\MultiDomainBundle\Controller; |
||
4 | |||
5 | use Kunstmaan\MultiDomainBundle\Helper\DomainConfiguration; |
||
6 | use Symfony\Component\Routing\Annotation\Route; |
||
7 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
||
8 | use Symfony\Component\HttpFoundation\RedirectResponse; |
||
9 | use Symfony\Component\HttpFoundation\Request; |
||
10 | use Symfony\Component\HttpFoundation\Response; |
||
11 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
12 | use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
||
13 | |||
14 | class SiteSwitchController extends Controller |
||
0 ignored issues
–
show
|
|||
15 | { |
||
16 | /** |
||
17 | * @Route("/switch-site", name="KunstmaanMultiDomainBundle_switch_site", methods={"GET"}) |
||
18 | * |
||
19 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
20 | * |
||
21 | * @return Response |
||
22 | * |
||
23 | * @throws AccessDeniedException |
||
24 | * @throws NotFoundHttpException |
||
25 | */ |
||
26 | public function switchAction(Request $request) |
||
27 | { |
||
28 | $domainConfiguration = $this->get('kunstmaan_admin.domain_configuration'); |
||
29 | $host = $request->query->get('host'); |
||
30 | $hosts = $domainConfiguration->getFullHostConfig(); |
||
31 | if (!\array_key_exists($host, $hosts)) { |
||
32 | throw $this->createNotFoundException('Invalid host specified'); |
||
33 | } |
||
34 | |||
35 | $currentHost = $domainConfiguration->getHost(); |
||
36 | |||
37 | $session = $request->getSession(); |
||
38 | if ($request->get('from_url_chooser')) { |
||
39 | $session->set(DomainConfiguration::SWITCH_HOST, $host); |
||
40 | } else { |
||
41 | $session->set(DomainConfiguration::OVERRIDE_HOST, $host); |
||
42 | } |
||
43 | |||
44 | /* |
||
45 | * If current host type is different then the host going to, redirect to it's homepage. |
||
46 | * If coming from url chooser, don't redirect to homepage if other host. |
||
47 | */ |
||
48 | if ((($hosts[$host]['type'] !== $hosts[$currentHost]['type']) || (!$request->query->has('route'))) && (!$request->get('from_url_chooser'))) { |
||
49 | $route = 'KunstmaanAdminBundle_homepage'; |
||
50 | $defaultLocale = $this->get('kunstmaan_admin.domain_configuration')->getDefaultLocale(); |
||
51 | } else { |
||
52 | $route = $request->query->get('route'); |
||
53 | $routeParams = $request->query->get('route_params'); |
||
54 | $defaultLocale = $hosts[$host]['default_locale']; |
||
55 | } |
||
56 | |||
57 | $routeParams['_locale'] = $defaultLocale; |
||
58 | |||
59 | $response = new RedirectResponse( |
||
60 | $this->get('router')->generate($route, $routeParams) |
||
61 | ); |
||
62 | |||
63 | return $response; |
||
64 | } |
||
65 | } |
||
66 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.