受信者フィールドフォームを非表示にしましたが、コントローラーのどこで受信者の値を伝えることができるかを理解したいと思います
メッセージコントローラー:
/**
* Create a new message thread
*
* @return Response
*/
public function newThreadAction()
{
$form = $this->container->get('fos_message.new_thread_form.factory')->create();
$formHandler = $this->container->get('fos_message.new_thread_form.handler');
if ($message = $formHandler->process($form)) {
return new RedirectResponse($this->container->get('router')->generate('fos_message_thread_view', array(
'threadId' => $message->getThread()->getId()
)));
}
return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:newThread.html.twig', array(
'form' => $form->createView(),
'data' => $form->getData()
));
}
$form 数学から:
class NewThreadMessageFormFactory extends AbstractMessageFormFactory
{
/**
* Creates a new thread message
*
* @return Form
*/
public function create()
{
$message = $this->createModelInstance();
return $this->formFactory->createNamed($this->formName, $this->formType, $message);
}
}
$formHandler の一致:
class NewThreadMessageFormHandler extends AbstractMessageFormHandler
{
/**
* Composes a message from the form data
*
* @param AbstractMessage $message
* @return MessageInterface the composed message ready to be sent
* @throws InvalidArgumentException if the message is not a NewThreadMessage
*/
public function composeMessage(AbstractMessage $message)
{
if (!$message instanceof NewThreadMessage) {
throw new \InvalidArgumentException(sprintf('Message must be a NewThreadMessage instance, "%s" given', get_class($message)));
}
return $this->composer->newThread()
->setSubject($message->getSubject())
->addRecipient($message->getRecipient())
->setSender($this->getAuthenticatedParticipant())
->setBody($message->getBody())
->getMessage();
}
}
いくつかの解決策があることを願っています!
どうもありがとう !