本文整理匯總了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));
}
}
}