实体经理无法找到自定义存储库类

时间:2017-08-24 08:19:18

标签: orm oauth-2.0 doctrine silex

请帮助我,我正在学习使用silex框架,我想将silex与dflydev(OAuth2)集成。但是对于doctrine orm提供者有错误:

  

致命错误:未捕获错误:类' OAuth2Test \ Server \ RepositoryOAuthClientRepository'在/var/www/html/firsttest/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:68中找不到堆栈跟踪:#0 / var / www / html / firsttest / vendor / doctrine / orm /lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php(50):Doctrine \ ORM \ Repository \ DefaultRepositoryFactory-> createRepository(Object(Doctrine \ ORM \ EntityManager),' OAuth2Test \ Serv ...&#39 ;)#1 /var/www/html/firsttest/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(698):Doctrine \ ORM \ Repository \ DefaultRepositoryFactory-> getRepository(Object(Doctrine \ ORM \) EntityManager),' OAuth2Test \ Serv ...')#2 /var/www/html/firsttest/src/OAuth2Test/Server/Controllers/Token.php(22):Doctrine \ ORM \ EntityManager- > getRepository(' OAuth2Test \ Serv ...')#3 [内部功能]:OAuth2Test \ Server \ Controllers \ Token-> OAuth2Test \ Server \ Controllers {closure}()#4 / var /www/html/firsttest/vendor/symfony/http-kernel/HttpKernel.php(153):call_user_func_array(Object(Closure),Array)/ var / www / html / f中的#5 / var / w第68行的irsttest / vendor / doctrine / orm / lib / Doctrine / ORM / Repository / DefaultRepositoryFactory.php

...

├── src
│   ├── app.php
│   ├── OAuth2Test
│   │   └── Server
│   │       ├── Controllers
│   │       ├── Entity
│   │       ├── Repository
│   │       └── Server.php
│   └── routes.php

autoload:

"autoload": {
    "psr-4": {"OAuth2Test\\": "src/OAuth2Test/"}
}

app.php:

$app->register(new DoctrineOrmServiceProvider, array(
    'orm.proxies_dir'           => __DIR__.'/OAuth2Test/Server/Entity/proxy',
    'orm.em.options'            => array(
        'mappings'  =>  array(
            array(
                'alias'                         => 'OAuth2Test',
                'type'                          => 'annotation',
                'namespace'                     => "OAuth2Test\Server\Entity",
                'resources_namespace'           => "OAuth2Test\Server\Entity",
                'path'                          => __DIR__."/OAuth2Test/Server/Entity",
                'use_simple_annotation_reader'  => false,
            ),
        ),
    ),
));

我的实体:

namespace OAuth2Test\Server\Entity;

use Doctrine\ORM\Mapping as ORM; 

/**
* @ORM\Entity(repositoryClass="OAuth2Test\Server\Repository\OAuthClientRepository")
*/
class OAuthClient extends EncryptableFieldEntity{

我的存储库:

namespace OAuth2Test\Server\Repository;

use Doctrine\ORM\EntityRepository;
use OAuth2\Storage\ClientCredentialsInterface;

class OAuthClientRepository extends EntityRepository implements ClientCredentialsInterface{

控制器(Token.php):

$controllers->post("/token", function() use($app){

    $clientStorage = $app['orm.em']->getRepository('OAuth2Test\Server\Entity\OAuthClient');
    $userStorage = $app['orm.em']->getRepository('OAuth2Test\Server\Entity\OAuthUser');
    $accessTokenStorage = $app['orm.em']->getRepository('OAuth2Test\Server\Entity\OAuthAccessToken');

    $server = new \OAuth2\Server([
        'client_credentials' => $clientStorage,
        'user_credentials'   => $userStorage,
        'access_token'       => $accessTokenStorage,
    ], [
        'auth_code_lifetime' => 30,
        'refresh_token_lifetime' => 30,
    ]);

   $app['oauth_server']  = $server;

   return app['oauth_server']->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
})
->bind('grant');

return $controllers;
也许有人可以帮助我。

pd:抱歉我的英语不好!

0 个答案:

没有答案