FOSOauthServerBundle __构造函数错误



我已经在Symfony 2中使用RESTful API一段时间了。一切似乎都很好,直到昨晚我创建了新的实体类。我在尝试请求访问令牌时出错。我收到以下错误消息:

Catchable Fatal Error: Argument 2 passed to
FOSOAuthServerBundleEventOAuthEvent::__construct() must be an
instance of FOSOAuthServerBundleModelClientInterface, instance of
TeamGraduateAPIBundleEntityClient given, called in /Volumes/SK Repo
1.0/Projects/Stalin Kay/Web Development/htdocs/TeamGraduate/tg-api/vendor/friendsofsymfony/oauth-server-bundle/FOS/OAuthServerBundle/Controller/AuthorizeController.php
on line 57 and defined 500 Internal Server Error -
ContextErrorException

请帮忙。我的s2项目使用文档中描述的FOSOauthServerBundle。如果我在Client中重写构造函数,它会抛出一个致命错误:无法调用构造函数。

编辑:

注意:只是要明确的是,在我根据更新的数据库生成新的实体之前,一切都很好。我还使用composer更新对项目的依赖项进行了更新。

AccessToken.php

<?php
// src/Acme/DemoBundle/Entity/AccessToken.php
namespace TeamGraduateAPIBundleEntity;
use FOSOAuthServerBundleEntityAccessToken as BaseAccessToken;
use DoctrineORMMapping as ORM;
/**
 * @ORMEntity
 */
class AccessToken extends BaseAccessToken
{
    /**
     * @ORMId
     * @ORMColumn(type="integer")
     * @ORMGeneratedValue(strategy="AUTO")
     */
    protected $id;
    /**
     * @ORMManyToOne(targetEntity="Client")
     * @ORMJoinColumn(nullable=false)
     */
    protected $client;
    /**
     * @ORMManyToOne(targetEntity="User")
     */
    protected $user;
}

AuthCode.php

<?php
// src/Acme/DemoBundle/Entity/AuthCode.php
namespace TeamGraduateAPIBundleEntity;
use FOSOAuthServerBundleEntityAuthCode as BaseAuthCode;
use DoctrineORMMapping as ORM;
/**
 * @ORMEntity
 */
class AuthCode extends BaseAuthCode
{
    /**
     * @ORMId
     * @ORMColumn(type="integer")
     * @ORMGeneratedValue(strategy="AUTO")
     */
    protected $id;
    /**
     * @ORMManyToOne(targetEntity="Client")
     * @ORMJoinColumn(nullable=false)
     */
    protected $client;
    /**
     * @ORMManyToOne(targetEntity="User")
     */
    protected $user;
}

Client.php

<?php
// src/Acme/DemoBundle/Entity/Client.php
namespace TeamGraduateAPIBundleEntity;
use FOSOAuthServerBundleEntityClient as BaseClient;
use DoctrineORMMapping as ORM;
/**
 * @ORMEntity
 */
class Client extends BaseClient
{
    /**
     * @ORMId
     * @ORMColumn(type="integer")
     * @ORMGeneratedValue(strategy="AUTO")
     */
    protected $id;
    public function __construct()
    {
        parent::__construct();
    }
}

RefreshToken.php

<?php
// src/Acme/DemoBundle/Entity/RefreshToken.php
namespace TeamGraduateAPIBundleEntity;
use FOSOAuthServerBundleEntityRefreshToken as BaseRefreshToken;
use DoctrineORMMapping as ORM;
/**
 * @ORMEntity
 */
class RefreshToken extends BaseRefreshToken
{
    /**
     * @ORMId
     * @ORMColumn(type="integer")
     * @ORMGeneratedValue(strategy="AUTO")
     */
    protected $id;
    /**
     * @ORMManyToOne(targetEntity="Client")
     * @ORMJoinColumn(nullable=false)
     */
    protected $client;
    /**
     * @ORMManyToOne(targetEntity="User")
     */
    protected $user;
}

我相信我已经找到了解决方案。

使用下面的命令创建一个FOS目录。该目录是在src 下创建的

php app/console doctrine:mapping:import --force TeamGraduateAPIBundle xml

解决方案:

删除目录,一切都应该正常。

相关内容

  • 没有找到相关文章