/** * {@inheritdoc} */ public function process(Email $model) { $issue_contexts = array_filter($model->getContexts(), function ($context) { return $context instanceof Issue; }); /* @var $issue Issue */ $issue = array_pop($issue_contexts); if ($this->request->getMethod() === 'GET') { $tos = $model->getTo(); $tos[] = $issue->getReporter()->getEmail(); $model->setTo($tos); $model->setSubject(sprintf('%s %s', $issue->getCode(), $issue->getSummary())); } parent::process($model); }
public function testProcessGetRequest() { $this->request->setMethod('GET'); $this->request->query->set('gridName', 'testGrid'); $this->request->query->set('from', '*****@*****.**'); $this->request->query->set('to', '*****@*****.**'); $this->request->query->set('subject', 'testSubject'); $this->nameFormatter->expects($this->any())->method('format')->with($this->isInstanceOf('Oro\\Bundle\\EmailBundle\\Tests\\Unit\\Fixtures\\Entity\\TestUser'))->will($this->returnValue('FirstName LastName')); $this->form->expects($this->once())->method('setData')->with($this->model); $this->form->expects($this->never())->method('submit'); $this->assertFalse($this->handler->process($this->model)); $this->assertEquals('testGrid', $this->model->getGridName()); $this->assertEquals('FirstName LastName <*****@*****.**>', $this->model->getFrom()); $this->assertEquals(array('FirstName LastName <*****@*****.**>'), $this->model->getTo()); $this->assertEquals('testSubject', $this->model->getSubject()); }
/** * @param EmailModel $emailModel */ protected function applyRecipients(EmailModel $emailModel) { $emailModel->setTo(array_merge($emailModel->getTo(), $this->getRecipients($emailModel, EmailRecipient::TO, true))); $emailModel->setCc(array_merge($emailModel->getCc(), $this->getRecipients($emailModel, EmailRecipient::CC))); $emailModel->setBcc(array_merge($emailModel->getBcc(), $this->getRecipients($emailModel, EmailRecipient::BCC))); }
/** * @param EmailModel $model * * @throws \InvalidArgumentException */ protected function assertModel(EmailModel $model) { if (!$model->getFrom()) { throw new \InvalidArgumentException('Sender can not be empty'); } if (!$model->getTo() && !$model->getCc() && !$model->getBcc()) { throw new \InvalidArgumentException('Recipient can not be empty'); } }
/** * @param Email $value * @param Constraint|EmailRecipients $constraint */ public function validate($value, Constraint $constraint) { if (!$value->getTo() && !$value->getCc() && !$value->getBcc()) { $this->context->addViolation($constraint->message); } }