/**
  * @Acl(
  *      id="orob2b_rfp_frontend_request_create",
  *      type="entity",
  *      class="OroB2BRFPBundle:Request",
  *      permission="CREATE",
  *      group_name="commerce"
  * )
  * @Route("/create", name="orob2b_rfp_frontend_request_create")
  * @Template("OroB2BRFPBundle:Request/Frontend:update.html.twig")
  *
  * @return array
  */
 public function createAction()
 {
     $rfpRequest = new RFPRequest();
     $user = $this->getUser();
     if ($user instanceof AccountUser) {
         $rfpRequest->setAccountUser($user)->setAccount($user->getAccount())->setFirstName($user->getFirstName())->setLastName($user->getLastName())->setCompany($user->getAccount()->getName())->setEmail($user->getEmail());
     }
     return $this->update($rfpRequest);
 }
예제 #2
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();
 }