0
我正在嘗試在asymfony2表單類型中使用doctrine。如何在symfony2中使用Doctrine AbstractType
在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
謝謝。