>我正在尝试创建自定义用户提供程序。
我将UserProvider
定义为服务:
myvendor.user_provider:
class: MyVendorUserBundleServiceSecurityUserProvider
此类是一个DocumentRepository
:
namespace MyVendorUserBundleServiceSecurity;
use SymfonyComponentSecurityCoreUserUserInterface;
use SymfonyComponentSecurityCoreUserUserProviderInterface;
use SymfonyComponentSecurityCoreExceptionUsernameNotFoundException;
use SymfonyComponentSecurityCoreExceptionUnsupportedUserException;
use DoctrineODMMongoDBDocumentRepository;
use DoctrineODMMongoDBDocumentNotFoundException;
class UserProvider extends DocumentRepository implements UserProviderInterface {
//public function loadUserBy...
}
但是我收到此错误:
Catchable Fatal Error: Argument 1 passed to DoctrineODMMongoDBDocumentRepository::__construct() must be an instance of DoctrineODMMongoDBDocumentManager, none given, called in /home/www/dev/public/myapp/app/cache/dev/appDevDebugProjectContainer.php on line 258 and defined in /home/www/dev/public/myapp/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/DocumentRepository.php line 68
似乎那时还没有创建文档管理器,因为我也尝试注入它,但它抱怨自己的依赖项,例如UnitOfWork
.
我能做什么?
服务定义很棘手
myvendor.user_provider:
class: MyVendorUserBundleServiceSecurityUserProvider
factory_service: doctrine.odm.mongodb
factory_method: getRepository
arguments: [ 'MyVendorUserBundle:UserUser' ]