【发布时间】:2023-03-03 02:57:01
【问题描述】:
我想从服务中取出我的表单,但无论我做什么,它都行不通。
我在 YML 中有服务
services:
myservice:
class: AppBundle\Service\Myservice
arguments: ["@doctrine.orm.entity_manager","@form.factory"]
然后在 AppBudle\Service\Myserivce.php:
namespace AppBundle\Service;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class Myservice {
protected $em;
protected $formFactory;
public function __construct(EntityManager $entityManager, FormFactoryInterface $formFactory) {
$this->em = $entityManager;
$this->formFactory = $formFactory;
}
// GENERATE CALCULATOR FORM
public function generateCalculatorForm() {
return 'ffffsdsd';
}
}
但我得到了一个
可捕获的致命错误:传递给 AppBundle\Service\Myservice::__construct() 的参数 2 必须是 AppBundle\Service\FormFactoryInterface 的实例,给定 Symfony\Component\Form\FormFactory 的实例,在 D:\xamp\ 中调用htdocs\icp\var\cache\dev\appDevDebugProjectContainer.php 在第 409 行并定义了
这里有什么问题?我已经尝试了我在网上找到的几乎所有东西,但无法正常工作。
【问题讨论】: