首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >FOSOauthServerBundle __constructor误差

FOSOauthServerBundle __constructor误差
EN

Stack Overflow用户
提问于 2015-11-06 15:18:22
回答 1查看 391关注 0票数 2

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

代码语言:javascript
运行
复制
Catchable Fatal Error: Argument 2 passed to
FOS\OAuthServerBundle\Event\OAuthEvent::__construct() must be an
instance of FOS\OAuthServerBundle\Model\ClientInterface, instance of
TeamGraduate\APIBundle\Entity\Client 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。如果我在客户端重写构造函数,它会抛出一个致命错误:无法调用构造函数。

编辑:

注意:为了清楚起见,在我根据更新的数据库生成新实体之前,一切都很好。我还使用composer update更新了项目的依赖项。

AccessToken.php

代码语言:javascript
运行
复制
<?php
// src/Acme/DemoBundle/Entity/AccessToken.php

namespace TeamGraduate\APIBundle\Entity;

use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class AccessToken extends BaseAccessToken
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="Client")
     * @ORM\JoinColumn(nullable=false)
     */
    protected $client;

    /**
     * @ORM\ManyToOne(targetEntity="User")
     */
    protected $user;
}

AuthCode.php

代码语言:javascript
运行
复制
<?php
// src/Acme/DemoBundle/Entity/AuthCode.php

namespace TeamGraduate\APIBundle\Entity;

use FOS\OAuthServerBundle\Entity\AuthCode as BaseAuthCode;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class AuthCode extends BaseAuthCode
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="Client")
     * @ORM\JoinColumn(nullable=false)
     */
    protected $client;

    /**
     * @ORM\ManyToOne(targetEntity="User")
     */
    protected $user;
}

Client.php

代码语言:javascript
运行
复制
<?php
// src/Acme/DemoBundle/Entity/Client.php

namespace TeamGraduate\APIBundle\Entity;

use FOS\OAuthServerBundle\Entity\Client as BaseClient;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class Client extends BaseClient
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    public function __construct()
    {
        parent::__construct();
    }
}

RefreshToken.php

代码语言:javascript
运行
复制
<?php
// src/Acme/DemoBundle/Entity/RefreshToken.php

namespace TeamGraduate\APIBundle\Entity;

use FOS\OAuthServerBundle\Entity\RefreshToken as BaseRefreshToken;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class RefreshToken extends BaseRefreshToken
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="Client")
     * @ORM\JoinColumn(nullable=false)
     */
    protected $client;

    /**
     * @ORM\ManyToOne(targetEntity="User")
     */
    protected $user;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-09 08:53:13

我相信我找到了解决办法。

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

代码语言:javascript
运行
复制
php app/console doctrine:mapping:import --force TeamGraduateAPIBundle xml

解决方案:

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33569964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档