public function importContacts($languageCode) { $mainContact = new JournalContact(); $contactName = !empty($this->settings[$languageCode]['contactName']) ? $this->settings[$languageCode]['contactName'] : null; $contactEmail = !empty($this->settings[$languageCode]['contactEmail']) ? $this->settings[$languageCode]['contactEmail'] : null; if ($contactName && $contactEmail) { $mainContact->setFullName($contactName); $mainContact->setEmail($contactEmail); if (!empty($this->settings[$languageCode]['contactPhone'])) { $mainContact->setPhone($this->settings[$languageCode]['contactPhone']); } if (!empty($this->settings[$languageCode]['contactMailingAddress'])) { $mainContact->setAddress($this->settings[$languageCode]['contactMailingAddress']); } } $supportContact = new JournalContact(); $supportName = !empty($this->settings[$languageCode]['supportName']) ? $this->settings[$languageCode]['supportName'] : null; $supportEmail = !empty($this->settings[$languageCode]['supportEmail']) ? $this->settings[$languageCode]['supportEmail'] : null; if ($supportName && $supportEmail) { $supportContact->setFullName($supportName); $supportContact->setEmail($supportEmail); if (!empty($this->settings[$languageCode]['supportPhone'])) { $supportContact->setPhone($this->settings[$languageCode]['supportPhone']); } if (!empty($this->settings[$languageCode]['mailingAddress'])) { $supportContact->setAddress($this->settings[$languageCode]['mailingAddress']); } } $type = $this->em->getRepository('OjsJournalBundle:ContactTypes')->findBy([], null, 1); if ($type) { $mainContact->setContactType($type[0]); $supportContact->setContactType($type[0]); } else { $newType = new ContactTypes(); $newType->setCurrentLocale(mb_substr($languageCode, 0, 2, 'UTF-8')); $newType->setName('Default'); $newType->setDescription('Default Type'); $this->em->persist($newType); $mainContact->setContactType($newType); $supportContact->setContactType($newType); } $this->journal->addJournalContact($mainContact); $this->journal->addJournalContact($supportContact); }