Php 如何在symfony2 AbstractType中使用原则

Php 如何在symfony2 AbstractType中使用原则,php,symfony,doctrine-orm,doctrine,Php,Symfony,Doctrine Orm,Doctrine,我试图在AsymMony2表单类型中使用原则 在services.yml中,我有: fyp_user.profile.form.type: class: FYP\UserBundle\Form\Type\ProfileFormType arguments: - fos_user.model.user.class - @doctrine.orm.entity_manager tags: - { name: form.type

我试图在AsymMony2表单类型中使用原则

在services.yml中,我有:

fyp_user.profile.form.type:
    class: FYP\UserBundle\Form\Type\ProfileFormType
    arguments: 
        - fos_user.model.user.class
        - @doctrine.orm.entity_manager
    tags:
        - { name: form.type, alias: fyp_user_profile }
我的班级看起来像:

use Doctrine\ORM\EntityManager;

class ProfileFormType extends AbstractType
{
    private $em;
    private $session;

    public function __construct(EntityManager $em)
    {
        $this->em = $em; 
    }   
我要做一些事情,比如:

 $cust =  $this->em->getRepository('MyBundle:Customers')->findOneByEmail($email);
我一直在

Type error: Argument 1 passed to FYP\UserBundle\Form\Type\ProfileFormType::__construct() must be an instance of Doctrine\ORM\EntityManager, string given, called in /Applications/MAMP/htdocs/upgrade/app/cache/dev/appDevDebugProjectContainer.php on line 3594

谢谢。

服务定义和类构造函数之间不匹配。在服务定义中有两个参数:
fos\u user.model.user.class
@doctor.orm.entity\u manager
,构造函数只接受一个(
EntityManager
)。只需从服务定义中的
参数列表中删除第一个条目,就可以了服务定义和类构造函数之间存在不匹配。在服务定义中有两个参数:
fos\u user.model.user.class
@doctor.orm.entity\u manager
,构造函数只接受一个(
EntityManager
)。只需从服务定义中的
参数列表中删除第一个条目,就可以了