Пример #1
0
 /**
  * @param \Sudoux\MortgageBundle\Entity\LoanApplication $application
  * @return string
  * @throws \Exception
  * @author Eric Haynes
  */
 public function upsertLoanToLos(LoanApplication $application)
 {
     try {
         $this->em->detach($application);
         $mismo = new LoanFormat($application);
         $mismoApp = $mismo->getMismo231();
         $xml = $this->container->get('templating')->render('SudouxMortgageBundle:LoanApplicationAdmin/formats:destiny.xml.twig', array('application' => $mismoApp), 'text/xml');
         /*
         $loId = null;
         $loanOfficer = $application->getLoanOfficer();
         if (isset($loanOfficer)) {
             $loId = $loanOfficer->getLosId();
         }
         
         $params = array(
             'vendor' => $this->losConnection->getUsername(),
             'cust' => $this->losConnection->getLicenseKey(),
             'LO' => $loId,
             'FNM' => $this->loanToFannieMae($application),
         );
         
         $request = $this->client->post($this::BASE_SERVICE_URL . '/process1003.ashx', array('Content-Type' => 'text/plain'), $params);
         
         $factory = new PhpStreamRequestFactory();
         $stream = $factory->fromRequest($request);
         $data = '';
         
         
         // Read until the stream is closed
         while (!$stream->feof()) {
             // Read a line from the stream
             $data .= $stream->readLine();
         
         }
         
         if (!is_numeric($data)) {
         
             $params = array(
                 'vendor' => $this->losConnection->getUsername(),
                 'cust' => $this->losConnection->getLicenseKey(),
                 'LO' => '',
                 'FNM' => $this->loanToFannieMae($application),
             );
         
             $request = $this->client->post($this::BASE_SERVICE_URL . '/process1003.ashx', array('Content-Type' => 'text/plain'), $params);
         
             $stream = $factory->fromRequest($request);
             $data = '';
         
         
             // Read until the stream is closed
             while (!$stream->feof()) {
                 // Read a line from the stream
                 $data .= $stream->readLine();
         
             }
         
         
         }
         */
         $data = 3;
         if (is_numeric($data)) {
             $application->setLosId($data);
             $modifiedDate = new \DateTime();
             $modifiedDate->getTimestamp();
             $application->setLosModified($modifiedDate);
             $application->setLosLoanNumber($data);
             $application->setStatus(1);
             // lookup lo
             if (isset($loId)) {
                 $losLoanOfficer = $this->em->getRepository('SudouxMortgageBundle:LoanOfficer')->findOneBySiteAndLosId($application->getSite(), $loId);
                 $application->setLoanOfficer($losLoanOfficer);
             } else {
                 $application->setLoanOfficer(null);
             }
             $this->em->persist($application);
             $this->em->flush();
         } else {
             $e = new \Exception("Error adding loan - ID: " . $application->getId() . " Exception: " . $data);
             $this->logger->crit($e->getMessage());
             throw $e;
         }
     } catch (\Exception $e) {
         $this->logger->crit($e->getMessage());
         throw $e;
     }
     return $data;
 }