/** * @param Form\FormBuilderInterface $builder * @param array $options */ public function buildForm(Form\FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', ['label' => 'ms.cms.blog_comment.form.name', 'constraints' => [new Constraints\NotBlank()], 'data' => !$this->_user instanceof User\AnonymousUser ? $this->_user->getName() : null]); $builder->add('email', 'email', ['label' => 'ms.cms.blog_comment.form.email', 'constraints' => [new Constraints\NotBlank(), new Constraints\Email()], 'data' => $this->_user->email]); $builder->add($builder->create('website', 'text', ['label' => 'ms.cms.blog_comment.form.website', 'constraints' => [new Constraints\Url()]])->addModelTransformer(new DataTransform\Url())); $builder->add('comment', 'textarea', ['label' => 'ms.cms.blog_comment.form.comment', 'constraints' => [new Constraints\NotBlank()]]); $builder->add('captcha', 'captcha', ['label' => 'ms.cms.blog_comment.form.captcha_prefix', 'constraints' => [new Constraints\NotBlank()]]); }
public function sendVoucher(Voucher $voucher, User\UserInterface $user) { if ($user instanceof User\AnonymousUser) { throw new \LogicException('Cannot send email to anonymous user!'); } $this->_message->setTo($user->email, $user->getName()); $this->_message->setSubject($this->_translator->trans('ms.voucher.evoucher.email.subject')); $this->_message->setView('Message:Mothership:Voucher::mail:evoucher', ['voucher' => $voucher, 'user' => $user]); $this->_send(); }