Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php FpOpenIdBundle实现接口错误_Php_Mongodb_Symfony - Fatal编程技术网

Php FpOpenIdBundle实现接口错误

Php FpOpenIdBundle实现接口错误,php,mongodb,symfony,Php,Mongodb,Symfony,我正在使用FpOpenIdBundle进行身份验证,但出现了此错误 可捕获的致命错误:传递给Fp\OpenIdBundle\Model\UserIdentity::setUser()的参数1必须实现接口Symfony\Component\Security\Core\User\UserInterface,即给定的条令\ODM\MongoDB\DocumentRepository实例,在第64行的C:\xampp\htdocs\project\src\AppBundle\Security\User\

我正在使用FpOpenIdBundle进行身份验证,但出现了此错误

可捕获的致命错误:传递给Fp\OpenIdBundle\Model\UserIdentity::setUser()的参数1必须实现接口Symfony\Component\Security\Core\User\UserInterface,即给定的条令\ODM\MongoDB\DocumentRepository实例,在第64行的C:\xampp\htdocs\project\src\AppBundle\Security\User\OpenIdUserManager.php中调用并定义

我跟着医生()

我已经成为了一名经理

namespace AppBundle\Security\User;

use AppBundle\Document\User;
use AppBundle\Document\OpenIdIdentity;
use Doctrine\ODM\MongoDB\DocumentManager;
use Fp\OpenIdBundle\Model\UserManager;
use Fp\OpenIdBundle\Model\IdentityManagerInterface;

class OpenIdUserManager extends UserManager
{
   /**
   * @var DocumentManager
   */
   private $documentManager;

    /**
    * OpenIdUserManager constructor.
    *
    * @param IdentityManagerInterface $identityManager
    * @param DocumentManager $documentManager
    */
    public function __construct(IdentityManagerInterface $identityManager, DocumentManager $documentManager)
    {
        parent::__construct($identityManager);

        $this->documentManager = $documentManager;
    }

    /**
     * @param string $identity
     * @param array $attributes
     *
     * @return \Doctrine\ODM\MongoDB\DocumentRepository
     */
     public function createUserFromIdentity($identity, array $attributes = array())
    {

        $user = $this->documentManager->getRepository('AppBundle:User');

        $openIdIdentity = new OpenIdIdentity();
        $openIdIdentity->setIdentity($identity);
        $openIdIdentity->setAttributes($attributes);
        $openIdIdentity->setUser($user);

        $this->documentManager->persist($openIdIdentity);
        $this->documentManager->flush();

        return $user;

    }
}
由于此行的原因,返回了错误

$openIdIdentity->setUser($user);
我用这个经理做这样的服务

services:
fp_openid.manager:
    class: AppBundle\Security\User\OpenIdUserManager
    arguments: [ '@fp_openid.identity_manager', '@doctrine.odm.mongodb.document_manager' ]
我的保安打电话给谁了。yml

security:
    firewalls:
       main:
           fp_openid:
               create_user_if_not_exists: true
               provider: openid_user_manager
    providers:
        openid_user_manager:
            id: fp_openid.manager
        main:
            entity:
                { class: AppBundle:User, property: personaName }
正如他们所说,我最终制作了一个MongoDB文档

namespace AppBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Symfony\Component\Security\Core\User\UserInterface;

use Fp\OpenIdBundle\Document\UserIdentity as BaseUserIdentity;

/**
 * @MongoDB\Document(collection="openid_identities")
 */
class OpenIdIdentity extends BaseUserIdentity
{
    /**
     * @MongoDB\Id(strategy="auto")
     */
    protected $id;

    /**
     * {@inheritdoc}
     * @MongoDB\String
     */
     protected $identity;

    /**
     * {@inheritdoc}
     * @MongoDB\Hash
     */
     protected $attributes;

    /**
     * @var UserInterface
     *
     * @MongoDB\ReferenceOne(targetDocument="AppBundle\Document\User", simple=true)
     */
     protected $user;

    public function __construct()
    {
        parent::__construct();
    }
}
除了这个问题,一切都很好,我不明白为什么这不起作用,而我做的和医生说的一样。我必须实现UserInterface而不是DocumentRepository的实例,但他们使用自己的用户文档

是否有人已经使用此捆绑包并出现此问题


感谢您的帮助

请再次仔细阅读文档,文档中有:

$user = $this->entityManager->getRepository('AcmeDemoBundle:User')->findOneBy(array(
    'email' => $attributes['contact/email']
));