예제 #1
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var RequestStatus $status */
     $status = $manager->getRepository('OroB2BRFPBundle:RequestStatus')->findOneBy([], ['id' => 'ASC']);
     if (!$status) {
         return;
     }
     /** @var Organization $organization */
     $organization = $this->getUser($manager)->getOrganization();
     foreach ($this->requests as $key => $rawRequest) {
         $request = new Request();
         $request->setFirstName($rawRequest['first_name'])->setLastName($rawRequest['last_name'])->setEmail($rawRequest['email'])->setPhone($rawRequest['phone'])->setCompany($rawRequest['company'])->setRole($rawRequest['role'])->setBody($rawRequest['body'])->setStatus($status)->setOrganization($organization);
         if (!empty($rawRequest['account'])) {
             $request->setAccount($this->getReference($rawRequest['account']));
         }
         if (!empty($rawRequest['accountUser'])) {
             $request->setAccountUser($this->getReference($rawRequest['accountUser']));
         }
         $manager->persist($request);
         $this->addReference($key, $request);
     }
     $manager->flush();
 }