public function getContacts() { $this->__load(); return parent::getContacts(); }
/** * Creates or updates customers contact from given member array by type. * * Function checks if contact exits for given type as role and contact name. If contact * is not existent then function creates contact and otherwise it updates it. * * @param string $type Contact type. Valid options: admin | tech | billing * @param \Entities\Customer $cust Customer to update or create contacts * @param array $member Members details array parsed from csv file. * @param object $em Doctrine entity manager. * @return void */ function createUpdateContact($type, $cust, $member, $em) { if ($type == 'admin') { $role_name = 'Admin'; } else { if ($type == 'tech') { $role_name = 'Technical'; } elseif ($type == 'billing') { $role_name = 'Billing'; } else { throw new Exception("Unknown type"); } } $role = $em->getRepository("\\Entities\\ContactGroup")->findOneBy(['name' => $role_name]); if ($member[$type . '_name'] || $member[$type . '_email'] || $member[$type . '_phone']) { $cont = false; if ($cust->getContacts()) { foreach ($cust->getContacts() as $tcont) { if ($tcont->getName() == $member[$type . '_name'] && $tcont->getGroups()->contains($role)) { $cont = $tcont; break; } } } if (!$cont) { $cont = new \Entities\Contact(); $em->persist($cont); $cont->setCreated(new \DateTime()); $cont->setName($member[$type . '_name'] ? $member[$type . '_name'] : "{$role_name} Contact"); $cont->addGroup($role); $cont->setCustomer($cust); $cont->setFacilityaccess(0); $cont->setMayauthorize(0); } $cont->setLastupdated(new \DateTime()); $cont->setEmail($member[$type . '_email']); $cont->setPhone($member[$type . '_phone']); if ($type == 'billing') { $cont->setNotes($member['billing_c2_notes']); } $cont->setLastupdatedby(null); } }