服务未触发:控制器必须返回响应(null给定) [英] Service not triggered : The controller must return a response (null given)

查看:327
本文介绍了服务未触发:控制器必须返回响应(null给定)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,非常感谢您的帮助,
我正在尝试FOSFacebook工作,但直到现在似乎都是不可能的。
我尝试了很多配置,很多修复,但对我没有任何作用。

Hi everyone and huge thanks for the help, I am trying to get FOSFacebook work, but it seems to be impossible until now. I tried a lot of configuration, and a lot of fix but nothing worked for me.

这是我的配置:

security.yml

chain_provider:
    chain:
        providers: [fos_userbundle, fos_facebook_provider]
fos_userbundle:
    id: fos_user.user_provider.username
fos_facebook_provider:
      id: fos.facebook.custom_provider

firewalls:
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false
    main:
        pattern: ^/
        form_login:  
            login_path: fos_user_security_login
            check_path: fos_user_security_check
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
        logout:       true
        anonymous:    true
    public:
          pattern:   ^/
          fos_facebook:
              app_url: "http://apps.facebook.com/myApp/"
              server_url: "http://www.mywebsite.com"
              login_path: /facebook/login
              check_path: /facebook/check
              default_target_path: /
              provider: fos_facebook_provider
          anonymous: false
          logout:
              handlers: ["fos_facebook.logout_handler"]

config.yml

fos.facebook.custom_provider:
    class: Bundles\UserBundle\Security\User\Provider\FacebookProvider
    arguments:
        facebook: "@fos_facebook.api"
        userManager: "@fos_user.user_manager"
        validator: "@validator"
        container: "@service_container"
fos_facebook:
    file:   %kernel.root_dir%/../vendor/facebook/php-sdk/src/base_facebook.php
    alias:  facebook
    app_id: myid
    secret: mysecret
    cookie: true
    permissions: [email]

routing.yml

    _security_check:
        pattern:  /facebook/check

    _security_logout:
        pattern:  /logout

Twig模板

<script type="text/javascript">
    function goLogIn(){
        window.location.href = "{{ path('_security_check') }}";
    }

    function onFbInit() {
        if (typeof(FB) != 'undefined' && FB != null ) {
            FB.Event.subscribe('auth.statusChange', function(response) {
                if (response.session || response.authResponse) {
                    setTimeout(goLogIn, 500);
                } else {
                    window.location.href = "{{ path('_security_logout') }}";
                }
            });
        }
    }
</script>
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();'}) }}

UserController.php

 * @Route("/facebook/check")
 */
 public function loginCheckFacebookAction(){

 }

提供者和对User类的修改(如自述)。

And the provider and the modification to User class (as in the Readme).

但问题是该服务似乎没有被调用。的确,UserController中的方法必须是一个虚拟方法,而不是在这里。
该方法被调用,当然我得到这个错误:

But the problem is that the service not seemed to be called. Indeed, the method in the UserController must be a dummy method, and it is not like that here. The method is called and of course I get this error :

LogicException:控制器必须返回一个响应(给定的null)。你忘了在你的控制器中添加一个return语句吗? (未捕获的例外)。

我的错误是什么?

推荐答案

删除您的UserController路线/动作 loginCheckFacebookAction

这篇关于服务未触发:控制器必须返回响应(null给定)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆