【发布时间】:2017-03-30 06:19:05
【问题描述】:
我没有使用 FOSUserBundle(已经有自定义用户/安全代码)。我一直在关注文档here。
在对 Symfony 和 FOSMessageBundle 文件进行大量搜索和挖掘之后,我开始相信这个问题与新的 NewThreadMessageFormFactory 类有关。它只有一种方法。如果我保持原样
public function create()
{
return $this->formFactory->createNamed(
$this->formName,
$this->formType,
$this->createModelInstance());
}
我收到此错误Expected argument of type "string", "AppBundle\Service\NewThreadMessageFormType" given。另一方面,如果我执行以下操作,
public function create()
{
return $this->formFactory->createNamed(
$this->formName,
'AppBundle\Service\NewThreadMessageFormType',
$this->createModelInstance());
}
我知道了Could not load type "FOS\UserBundle\Form\Type\UsernameFormType。当然,它甚至不存在,因为 FOSUserBundle 甚至没有安装。
我已经为此花费了十几个小时。我在这个过程中学到了很多东西,但我仍然无法让这该死的东西发挥作用......
还有我目前的配置
//config.yml
fos_message:
db_driver: orm
thread_class: AppBundle\Entity\Thread
message_class: AppBundle\Entity\Message
new_thread_form:
type: app.new_thread_form_type
factory: app.new_thread_form_factory
还有……
//services.yml
fos_user.user_to_username_transformer:
alias: app.user_to_username_transformer
app.user_to_username_transformer:
class: AppBundle\Form\DataTransformer\UserToUsernameTransformer
arguments:
type: "service"
id: "doctrine"
app.new_thread_form_type:
class: AppBundle\Service\NewThreadMessageFormType
arguments: ['@app.user_to_username_transformer']
tags:
- {name: form.type}
app.new_thread_form_factory:
class: AppBundle\Service\NewThreadMessageFormFactory
arguments: [
'@form.factory',
'@fos_message.new_thread_form.type',
'%fos_message.new_thread_form.name%',
'%fos_message.new_thread_form.model%'
]
【问题讨论】:
标签: php symfony yaml symfony-3.2