/** * {@inheritdoc} */ public function load(ObjectManager $manager) { // phone types $metadata = $manager->getClassMetaData(PhoneType::class); $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $phoneType1 = new PhoneType(); $phoneType1->setId(1); $phoneType1 = $manager->merge($phoneType1); $phoneType1->setName('phone.work'); $phoneType2 = new PhoneType(); $phoneType2->setId(2); $phoneType2 = $manager->merge($phoneType2); $phoneType2->setName('phone.home'); $phoneType3 = new PhoneType(); $phoneType3->setId(3); $phoneType3 = $manager->merge($phoneType3); $phoneType3->setName('phone.mobile'); // email types $metadata = $manager->getClassMetaData(EmailType::class); $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $emailType1 = new EmailType(); $emailType1->setId(1); $emailType1 = $manager->merge($emailType1); $emailType1->setName('email.work'); $this->addReference('email.type.work', $emailType1); $emailType2 = new EmailType(); $emailType2->setId(2); $emailType2 = $manager->merge($emailType2); $emailType2->setName('email.home'); $this->addReference('email.type.home', $emailType2); // address types $metadata = $manager->getClassMetaData(AddressType::class); $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $addressType1 = new AddressType(); $addressType1->setId(1); $addressType1 = $manager->merge($addressType1); $addressType1->setName('address.work'); $addressType2 = new AddressType(); $addressType2->setId(2); $addressType2 = $manager->merge($addressType2); $addressType2->setName('address.home'); // url types $metadata = $manager->getClassMetaData(UrlType::class); $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $urlType1 = new UrlType(); $urlType1->setId(1); $urlType1 = $manager->merge($urlType1); $urlType1->setName('url.work'); $urlType2 = new UrlType(); $urlType2->setId(2); $urlType2 = $manager->merge($urlType2); $urlType2->setName('url.home'); // fax types $metadata = $manager->getClassMetaData(FaxType::class); $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $faxType1 = new FaxType(); $faxType1->setId(1); $faxType1 = $manager->merge($faxType1); $faxType1->setName('fax.work'); $faxType2 = new FaxType(); $faxType2->setId(2); $faxType2 = $manager->merge($faxType2); $faxType2->setName('fax.home'); $manager->flush(); }
private function initOrm() { $account = new Account(); $account->setName('Company'); $account->setPlaceOfJurisdiction('Feldkirch'); $parentAccount = new Account(); $parentAccount->setName('Parent'); $parentAccount->setPlaceOfJurisdiction('Feldkirch'); $childAccount = new Account(); $childAccount->setName('Child'); $childAccount->setPlaceOfJurisdiction('Feldkirch'); $childAccount->setParent($parentAccount); $this->account = $account; $this->childAccount = $childAccount; $this->parentAccount = $parentAccount; $urlType = new UrlType(); $urlType->setName('Private'); $this->urlType = $urlType; $url = new Url(); $url->setUrl('http://www.company.example'); $this->url = $url; $url->setUrlType($urlType); $account->addUrl($url); $this->emailType = new EmailType(); $this->emailType->setName('Private'); $this->email = new Email(); $this->email->setEmail('*****@*****.**'); $this->email->setEmailType($this->emailType); $account->addEmail($this->email); $phoneType = new PhoneType(); $phoneType->setName('Private'); $this->phoneType = $phoneType; $phone = new Phone(); $phone->setPhone('123456789'); $phone->setPhoneType($phoneType); $account->addPhone($phone); $faxType = new FaxType(); $faxType->setName('Private'); $this->faxType = $faxType; $fax = new Fax(); $fax->setFax('123654789'); $fax->setFaxType($faxType); $account->addFax($fax); $country = new Country(); $country->setName('Musterland'); $country->setCode('ML'); $this->country = $country; $addressType = new AddressType(); $addressType->setName('Private'); $this->addressType = $addressType; $address = new Address(); $address->setStreet('Musterstraße'); $address->setNumber('1'); $address->setZip('0000'); $address->setCity('Musterstadt'); $address->setState('Musterland'); $address->setCountry($country); $address->setAddition(''); $address->setAddressType($addressType); $address->setBillingAddress(true); $address->setPrimaryAddress(true); $address->setDeliveryAddress(false); $address->setPostboxCity('Dornbirn'); $address->setPostboxPostcode('6850'); $address->setPostboxNumber('4711'); $address->setNote('note'); $this->address = $address; $accountAddress = new AccountAddress(); $accountAddress->setAddress($address); $accountAddress->setAccount($account); $accountAddress->setMain(true); $account->addAccountAddress($accountAddress); $address->addAccountAddress($accountAddress); $contact = new Contact(); $contact->setFirstName('Vorname'); $contact->setLastName('Nachname'); $contact->setMiddleName('Mittelname'); $contact->setFormOfAddress(0); $accountContact = new AccountContact(); $accountContact->setContact($contact); $accountContact->setAccount($account); $accountContact->setMain(true); $account->addAccountContact($accountContact); $note = new Note(); $note->setValue('Note'); $account->addNote($note); $this->initLogo(); $account->setLogo($this->logo); $this->em->persist($account); $this->em->persist($childAccount); $this->em->persist($parentAccount); $this->em->persist($urlType); $this->em->persist($url); $this->em->persist($this->emailType); $this->em->persist($accountContact); $this->em->persist($this->email); $this->em->persist($phoneType); $this->em->persist($phone); $this->em->persist($country); $this->em->persist($addressType); $this->em->persist($address); $this->em->persist($accountAddress); $this->em->persist($note); $this->em->persist($faxType); $this->em->persist($fax); $this->em->persist($contact); $this->em->flush(); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $phoneType1 = new PhoneType(); $phoneType1->setId(1); // force id = 1 $metadata = $manager->getClassMetaData(get_class($phoneType1)); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $phoneType1->setName('phone.work'); $manager->persist($phoneType1); $phoneType2 = new PhoneType(); $phoneType2->setId(2); $phoneType2->setName('phone.home'); $manager->persist($phoneType2); $phoneType3 = new PhoneType(); $phoneType3->setId(3); $phoneType3->setName('phone.mobile'); $manager->persist($phoneType3); $emailType1 = new EmailType(); $emailType1->setId(1); // force id = 1 $metadata = $manager->getClassMetaData(get_class($emailType1)); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $emailType1->setName('email.work'); $manager->persist($emailType1); $this->addReference('email.type.work', $emailType1); $emailType2 = new EmailType(); $emailType2->setId(2); $emailType2->setName('email.home'); $manager->persist($emailType2); $this->addReference('email.type.home', $emailType2); $addressType1 = new AddressType(); $addressType1->setId(1); // force id = 1 $metadata = $manager->getClassMetaData(get_class($addressType1)); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $addressType1->setName('address.work'); $manager->persist($addressType1); $addressType2 = new AddressType(); $addressType2->setId(2); $addressType2->setName('address.home'); $manager->persist($addressType2); $urlType1 = new UrlType(); $urlType1->setId(1); // force id = 1 $metadata = $manager->getClassMetaData(get_class($urlType1)); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $urlType1->setName('url.work'); $manager->persist($urlType1); $urlType2 = new UrlType(); $urlType2->setId(2); $urlType2->setName('url.home'); $manager->persist($urlType2); $manager->flush(); $faxType1 = new FaxType(); $faxType1->setId(1); // force id = 1 $metadata = $manager->getClassMetaData(get_class($faxType1)); $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE); $faxType1->setName('fax.work'); $manager->persist($faxType1); $faxType2 = new FaxType(); $faxType2->setId(2); $faxType2->setName('fax.home'); $manager->persist($faxType2); $manager->flush(); }