简体   繁体   English

在用户实体提供Symfony2的致命错误

[英]Symfony2 Fatal error in Users Entity Provider

I'm using symfony 2.3.4 and in security configuration I want to to load Security Users from the Database accordingly to this Cookbook instruction . 我使用的是symfony 2.3.4,在安全配置中,我想从数据库中向此Cookbook指令加载安全用户。 But I only get this error: 但是我只得到这个错误:

Fatal error: Class MyApp\\AdminBundle\\Entity\\Users contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (Symfony\\Component\\Security\\Core\\User\\UserInterface::getRoles, Symfony\\Component\\Security\\Core\\User\\UserInterface::getUsername, Symfony\\Component\\Security\\Core\\User\\UserInterface::eraseCredentials) in /Volumes/Htdocs/symfony/src/MyApp/AdminBundle/Entity/Users.php 致命错误:类MyApp \\ AdminBundle \\ Entity \\ Users包含3个抽象方法,因此必须声明为抽象或实现其余方法(Symfony \\ Component \\ Security \\ Core \\ User \\ UserInterface :: getRoles,Symfony \\ Component \\ Security \\ Core \\ /Volumes/Htdocs/symfony/src/MyApp/AdminBundle/Entity/Users.php中的User \\ UserInterface :: getUsername,Symfony \\ Component \\ Security \\ Core \\ User \\ UserInterface :: eraseCredentials)

Symfony's security framework expects the User entity to implement the UserInterface . Symfony的安全框架期望User实体实现UserInterface Implement the three methods: 实现三种方法:

public function getRoles()
public function getUsername()
public function eraseCredentials()

Just implement the methods from the interface. 只需从接口实现方法即可。 ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM