Symfony 2.8 -> 3.4 Upgrade IsGranted('IS_AUTHENTICATED_ANONYMOUSLY') Throws Errors

前端 未结 3 628
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 07:02

I\'m in the process of upgrading Symfony from 2.8 to 3.4 and I have a Authentication Listener.

The constructor of the listener

  public function __co         


        
3条回答
  •  别那么骄傲
    2021-01-20 07:39

    Issue was with the priority order.

    thanks @cerad for giving a clue about it

    bin/console debug:event-dispatcher kernel.request
    

    helped to solve the issue. i was using

    tags:
            - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse, priority: 10 }
    

    in Services.yml and it had a conflict with the

    getSubscribedEvents()
    

    therefore i have removed tags and only kept

    public static function getSubscribedEvents()
        {
            return array(
                KernelEvents::REQUEST  => array('onKernelRequest', 10),
            );
        }
    

    then i moved authentication listener to the down by giving high priority to other two listeners as same as it was there in symfony 2.8

    Thanks all for helping me out on this specially @Pie @Cerad and @BoShurik

提交回复
热议问题