本文整理汇总了PHP中Oro\Bundle\EmailBundle\Entity\Email::getRecipients方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::getRecipients方法的具体用法?PHP Email::getRecipients怎么用?PHP Email::getRecipients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EmailBundle\Entity\Email
的用法示例。
在下文中一共展示了Email::getRecipients方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRecipientGetterAndSetter
public function testRecipientGetterAndSetter()
{
$toRecipient = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailRecipient');
$toRecipient->expects($this->any())->method('getType')->will($this->returnValue('to'));
$ccRecipient = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailRecipient');
$ccRecipient->expects($this->any())->method('getType')->will($this->returnValue('cc'));
$bccRecipient = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailRecipient');
$bccRecipient->expects($this->any())->method('getType')->will($this->returnValue('bcc'));
$entity = new Email();
$entity->addRecipient($toRecipient);
$entity->addRecipient($ccRecipient);
$entity->addRecipient($bccRecipient);
$recipients = $entity->getRecipients();
$this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $recipients);
$this->assertCount(3, $recipients);
$this->assertTrue($toRecipient === $recipients[0]);
$this->assertTrue($ccRecipient === $recipients[1]);
$this->assertTrue($bccRecipient === $recipients[2]);
/** @var GroupNodeDefinition $recipients */
$recipients = $entity->getRecipients('to');
$this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $recipients);
$this->assertCount(1, $recipients);
$this->assertTrue($toRecipient === $recipients->first());
$recipients = $entity->getRecipients('cc');
$this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $recipients);
$this->assertCount(1, $recipients);
$this->assertTrue($ccRecipient === $recipients->first());
$recipients = $entity->getRecipients('bcc');
$this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $recipients);
$this->assertCount(1, $recipients);
$this->assertTrue($bccRecipient === $recipients->first());
}
示例2: getEmails
/**
* Gets all(FROM, TO, CC, BCC) emails.
*
* @param Email $email
*
* @return string[]
*/
protected function getEmails(Email $email)
{
$emails = [];
foreach ($email->getRecipients() as $recipient) {
$emails[] = $recipient->getEmailAddress()->getEmail();
}
$emails[] = $email->getFromEmailAddress()->getEmail();
return array_unique($emails);
}
示例3: addRecipientOwners
/**
* @param array $targets
* @param Email $email
*/
protected function addRecipientOwners(&$targets, Email $email)
{
$recipients = $email->getRecipients();
foreach ($recipients as $recipient) {
$owner = $recipient->getEmailAddress()->getOwner();
if ($owner) {
$this->addTarget($targets, $owner);
}
}
}
示例4: processRecipients
/**
* @param Email $email
* @param string $type
* @param string[] $recipients
*/
protected function processRecipients(Email $email, $type, array $recipients)
{
if ($email->getId()) {
$existingRecipients = $email->getRecipients($type);
if (!$this->areRecipientsEqual($existingRecipients, $recipients)) {
throw $this->createInvalidPropertyException(sprintf('"%s" recipients', $type), $this->convertRecipientsToString($existingRecipients), $this->convertRecipientsToString($recipients));
}
} else {
foreach ($recipients as $recipient) {
$email->addRecipient($this->emailEntityBuilder->recipient($type, $recipient));
}
}
}