]> Raphaël G. Git Repositories - userbundle/blobdiff - Handler/LogoutSuccessHandler.php
Replace logout success handler with default logout listener
[userbundle] / Handler / LogoutSuccessHandler.php
index de862d5a88410b06e096be7d230e3476856844d0..4c194c5be8df25f96ec95f0eb559bbe5eb5f8d35 100644 (file)
@@ -1,10 +1,20 @@
-<?php
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys UserBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
 
 namespace Rapsys\UserBundle\Handler;
 
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Request;
 
 namespace Rapsys\UserBundle\Handler;
 
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Routing\Exception\ResourceNotFoundException;
 use Symfony\Component\Routing\RequestContext;
 use Symfony\Component\Routing\RouterInterface;
 use Symfony\Component\Routing\Exception\ResourceNotFoundException;
 use Symfony\Component\Routing\RequestContext;
 use Symfony\Component\Routing\RouterInterface;
@@ -37,7 +47,7 @@ class LogoutSuccessHandler extends DefaultLogoutSuccessHandler {
         *
         * {@inheritdoc}
         */
         *
         * {@inheritdoc}
         */
-       public function __construct(ContainerInterface $container, string $targetUrl = '/', RouterInterface $router) {
+       public function __construct(ContainerInterface $container, string $targetUrl, RouterInterface $router) {
                //Set config
                $this->config = $container->getParameter(self::getAlias());
 
                //Set config
                $this->config = $container->getParameter(self::getAlias());
 
@@ -51,7 +61,7 @@ class LogoutSuccessHandler extends DefaultLogoutSuccessHandler {
        /**
         * {@inheritdoc}
         */
        /**
         * {@inheritdoc}
         */
-       public function onLogoutSuccess(Request $request) {
+       public function onLogoutSuccess(Request $request): Response {
                //Retrieve logout route
                $logout = $request->get('_route');
 
                //Retrieve logout route
                $logout = $request->get('_route');
 
@@ -113,7 +123,7 @@ class LogoutSuccessHandler extends DefaultLogoutSuccessHandler {
                //With index route from config
                if (!empty($name = $this->config['route']['index']['name']) && is_array($context = $this->config['route']['index']['context'])) {
                        //Without logout route name
                //With index route from config
                if (!empty($name = $this->config['route']['index']['name']) && is_array($context = $this->config['route']['index']['context'])) {
                        //Without logout route name
-                       if (($name = $route['_route']) != $logout) {
+                       if ($name != $logout) {
                                //Try index route
                                try {
                                        //Generate url
                                //Try index route
                                try {
                                        //Generate url