Beispiel #1
0
 /**
  * @param string $key
  * @param Lead   $entity
  */
 public function fillEntityData($key, $entity)
 {
     $addressRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\AddressBundle\\Entity\\Address');
     $userRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\UserBundle\\Entity\\User');
     $customerRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer');
     $contactRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact');
     $channelRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel');
     $organizationRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization');
     switch ($key) {
         case 'Jerry Coleman':
             $entity->setName('Oro Inc. Lead Name');
             $entity->setCompanyName('Oro Inc.');
             $entity->setOwner($userRepo->getEntity('John Doo'));
             $entity->setOrganization($organizationRepo->getEntity('default'));
             $entity->setDataChannel($channelRepo->getEntity('B2b channel|b2b'));
             $entity->setCreatedAt(new \DateTime());
             $entity->setUpdatedAt(new \DateTime());
             $entity->setCustomer($customerRepo->getEntity('Jerry Coleman'));
             $entity->setContact($contactRepo->getEntity('Jerry Coleman'));
             $entity->setAddress($addressRepo->getEntity('Jerry Coleman'));
             $entity->setEmail('*****@*****.**');
             $entity->setNamePrefix('Mr.');
             $entity->setFirstName('Jerry');
             $entity->setLastName('Coleman');
             $entity->setNameSuffix('Jr.');
             $entity->setStatus(new LeadStatus('New'));
             $entity->setJobTitle('Manager');
             $entity->setPhoneNumber('585-255-1127');
             $entity->setWebsite('http://orocrm.com');
             $entity->setNumberOfEmployees(100);
             $entity->setIndustry('Internet');
             return;
     }
     parent::fillEntityData($key, $entity);
 }
 protected function createLead()
 {
     $lead = new Lead();
     $lead->setDataChannel($this->getReference('default_channel'));
     $lead->setName('Lead name');
     $lead->setFirstName('fname');
     $lead->setLastName('lname');
     $lead->setCustomer($this->getReference('default_b2bcustomer'));
     $lead->setEmail('*****@*****.**');
     $lead->setOrganization($this->organization);
     $this->em->persist($lead);
     $this->em->flush();
     $this->setReference('default_lead', $lead);
     return $this;
 }
Beispiel #3
0
 /**
  * @param  array $data
  * @param User $user
  *
  * @return Lead
  */
 protected function createLead(array $data, $user)
 {
     $lead = new Lead();
     /** @var LeadStatus $defaultStatus */
     $defaultStatus = $this->em->find('OroCRMSalesBundle:LeadStatus', 'new');
     $lead->setStatus($defaultStatus);
     $lead->setName($data['Company']);
     $lead->setFirstName($data['GivenName']);
     $lead->setLastName($data['Surname']);
     $lead->setEmail($data['EmailAddress']);
     $lead->setPhoneNumber($data['TelephoneNumber']);
     $lead->setCompanyName($data['Company']);
     $lead->setOwner($user);
     $lead->setOrganization($this->organization);
     $lead->setDataChannel($this->getReference('default_channel'));
     /** @var Address $address */
     $address = new Address();
     $address->setLabel('Primary Address');
     $address->setCity($data['City']);
     $address->setStreet($data['StreetAddress']);
     $address->setPostalCode($data['ZipCode']);
     $address->setFirstName($data['GivenName']);
     $address->setLastName($data['Surname']);
     $isoCode = $data['Country'];
     $country = array_filter($this->countries, function (Country $a) use($isoCode) {
         return $a->getIso2Code() == $isoCode;
     });
     $country = array_values($country);
     /** @var Country $country */
     $country = $country[0];
     $idRegion = $data['State'];
     /** @var Collection $regions */
     $regions = $country->getRegions();
     $region = $regions->filter(function (Region $a) use($idRegion) {
         return $a->getCode() == $idRegion;
     });
     $address->setCountry($country);
     if (!$region->isEmpty()) {
         $address->setRegion($region->first());
     }
     $lead->setAddress($address);
     return $lead;
 }