/** * @param \Symfony\Component\Form\FormInterface $form * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ protected function submitCommentForm(Request $request, FormInterface $form) { $formData = $form->getData(); $idSalesOrder = $formData[CommentTransfer::FK_SALES_ORDER]; if ($form->isValid()) { $commentTransfer = new CommentTransfer(); $commentTransfer->setMessage($formData[CommentTransfer::MESSAGE]); $commentTransfer->setFkSalesOrder($idSalesOrder); $currentUserTransfer = $this->getFactory()->getUserFacade()->getCurrentUser(); $commentTransfer->setUsername($currentUserTransfer->getFirstName() . ' ' . $currentUserTransfer->getLastName()); $this->getFacade()->saveComment($commentTransfer); $this->addSuccessMessage('Comment successfully added'); return $this->redirectResponse($request->headers->get('referer')); } else { foreach ($form->getErrors(true) as $error) { $this->addErrorMessage($error->getMessage()); } } }
/** * @param \Generated\Shared\Transfer\CommentTransfer $commentTransfer * @param \Orm\Zed\Sales\Persistence\SpySalesOrderComment $commentEntity * * @return void */ protected function hydrateCommentTranferFromEntity(CommentTransfer $commentTransfer, SpySalesOrderComment $commentEntity) { $commentTransfer->fromArray($commentEntity->toArray(), true); }