public function testOrganization() { $entity = new Group(); $organization = new Organization(); $this->assertNull($entity->getOrganization()); $entity->setOrganization($organization); $this->assertSame($organization, $entity->getOrganization()); }
public function load(ObjectManager $manager) { $entityManager = $this->container->get('doctrine.orm.entity_manager'); $saleUser = $this->getUser($manager, 'sale'); $groups = array('Behavioural Segmentation' => $saleUser, 'Demographic Segmentation' => $this->getUser($manager, 'marketing'), 'Geographic Segmentation' => $saleUser, 'Segmentation by occasions' => $saleUser, 'Segmentation by benefits' => $saleUser); foreach ($groups as $group => $user) { $contactGroup = new Group($group); $contactGroup->setOwner($user); $contactGroup->setOrganization($this->getReference('default_organization')); $entityManager->persist($contactGroup); } $entityManager->flush(); }
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); } }