我正在开发一个由Symfony 3支持的RESTful应用程序,使用FOSRestBundle、FOSUserBundle和FOSOAuthBundle。
类型错误:传递给FOS\UserBundle\Doctrine\UserManager的参数1:\uu construct()必须实现接口FOS\UserBundle\Util\PasswordUpdaterInterface,未给定,在/var/www/html/var/cache/dev/appDevDebugProjectContainer中调用。php在线2538
以下是我的部分应用程序文件:
# app/config/config.yml
fos_user:
# [...]
service:
user_manager: foo.user_manager
# src/FooBundle/Resources/config/services.yml
services:
# [...]
foo.user_manager:
class: FooBundle\Service\UserManager
FooBundle\Service\UserManager:
arguments:
$class: '%fos_user.model.user.class%'
<?php
// src/FooBundle/Service/UserManager.php
namespace FooBundle\Service;
use FOS\UserBundle\Doctrine\UserManager as BaseUserManager;
class UserManager extends BaseUserManager implements UserManagerInterface
{
/**
* {@inheritDoc}
* @see \FooBundle\Service\UserManagerInterface::findUsersAtPage()
*/
public function findUsersAtPage($usersPerPage, $page) {
$offset = $usersPerPage * $page;
return $this->getRepository()->findBy(array(), null, $usersPerPage, $offset);
}
}
<?php
// src/FooBundle/Service/UserManagerInterface.php
namespace FooBundle\Service;
use FOS\UserBundle\Model\UserManagerInterface as BaseUserManagerInterface;
interface UserManagerInterface extends BaseUserManagerInterface
{
/**
* Returns a collection with specified number of user instances at specified page.
* @param int $usersPerPage The number of users per page.
* @param int $page The page number.
* @return \Traversable
*/
public function findUsersAtPage($usersPerPage, $page);
}
<?php
// var/cache/dev/appDevDebugProjectContainer.php
class appDevDebugProjectContainer extends Container
{
// [...]
protected function getFosUser_UserManagerService()
{
return $this->services['fos_user.user_manager'] = new \FOS\UserBundle\Doctrine\UserManager(${($_ = isset($this->services['fos_user.util.password_updater']) ? $this->services['fos_user.util.password_updater'] : $this->getFosUser_Util_PasswordUpdaterService()) && false ?: '_'}, ${($_ = isset($this->services['fos_user.util.canonical_fields_updater']) ? $this->services['fos_user.util.canonical_fields_updater'] : $this->getFosUser_Util_CanonicalFieldsUpdaterService()) && false ?: '_'}, ${($_ = isset($this->services['fos_user.object_manager']) ? $this->services['fos_user.object_manager'] : $this->getFosUser_ObjectManagerService()) && false ?: '_'}, 'FooBundle\\Entity\\User');
}
// [...]
}
当我使用我的时(没有参数):
<?php
// var/cache/dev/appDevDebugProjectContainer.php
class appDevDebugProjectContainer extends Container
{
// [...]
protected function getFosUser_UserManagerService()
{
return $this->services['fos_user.user_manager'] = new \FooBundle\Service\UserManager();
}
// [...]
}
拜托,有人能帮我吗?