/編輯/從自定義類調用主義
我有這個類:
namespace Baza\BlogBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityManager;
class filterType extends AbstractType
{
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$this->$em->getDoctrine()->getEntityManager();
/****
****/
}
}
這是我的服務陽明:
services:
filterType:
class: Baza\BlogBundle\Form\filterType
arguments: [doctrine.orm.entity_manager]
當我運行代碼,我得到以下例外:
Catchable Fatal Error: Argument 1 passed to Baza\BlogBundle\Form\filterType::__construct() must be an instance of Doctrine\ORM\EntityManager, none given
我完全沒有想法。
嘗試:'arguments:[@ doctrine.orm.entity_manager]'添加了@,不知道它的含義,但是我所有的Symfony代碼都使用它。 – phpisuber01
我試過了,我得到:「在掃描下一個令牌時,ScannerException發現字符@(64)無法啓動任何令牌」。 – Xardas
確保您的空間數量正確。 –