public function testLabel() { $this->assertNull($this->group->getLabel()); $this->group->setLabel('Label'); $this->assertEquals('Label', $this->group->getLabel()); $this->assertEquals('Label', $this->group->__toString()); }
protected function sendEmail(Letter $letter, ContactGroup $contactGroup, $callback = null) { $stmt = $this->em->getConnection()->prepare('select contact_id from orocrm_contact_to_contact_grp where contact_group_id = :group_id'); $stmt->bindValue(':group_id', $contactGroup->getId()); $stmt->execute(); $contactIds = $stmt->fetchAll(); if (!count($contactIds)) { echo sprintf('No Contacts Found in Group %s', $contactGroup->getLabel()); exit; } foreach ($contactIds as $contactId) { $contact = $this->em->getRepository('OroCRMContactBundle:Contact')->find($contactId['contact_id']); $email = $contact->getEmail(); $message = \Swift_Message::newInstance()->setSubject($letter->getSubject())->setFrom('*****@*****.**', 'Vladimir Drizheruk')->setTo('*****@*****.**')->setBody($letter->getBody(), 'text/html'); if ($this->mailer->send($message)) { echo sprintf("Send to %s", $email) . PHP_EOL . PHP_EOL; } unset($email); unset($message); } }