Controller
$formData = $form->getData();
if ($form->isSubmitted() && $form->isValid()) {
$contactService->send(new ContactUsValueObject('Contact form message', $formData['fullname'], $formData['email'], $formData['email'], $formData['message']));
}
Service
public function send(ContactUsValueObject $contactUsValueObject, string $renderTemplate): bool
{
$message = (new \Swift_Message($contactUsValueObject->getTitle()))
->setFrom($contactUsValueObject->getEmail())
->setTo($this->parameterBag->get('contact_email'))
->setBody(
$this->twig->render(
$renderTemplate,
[
//value object here
]
),
'text/html'
);
return (boolean)$this->mailer->send($message);
}
Правильно ли так писать