generate() публичный Метод

public generate ( Sonata\Component\Order\OrderInterface $order ) : string
$order Sonata\Component\Order\OrderInterface
Результат string
Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function sendbank(OrderInterface $order)
 {
     $params = array('bank' => $this->getCode(), 'reference' => $order->getReference(), 'check' => $this->generateUrlCheck($order));
     $cmdLineParameters = array('merchant_id' => $this->getOption('merchant_id'), 'merchant_country' => $this->getOption('merchant_country'), 'pathfile' => $this->getOption('pathfile'), 'language' => $this->getLanguage($order), 'payment_means' => $this->getOption('payment_means'), 'header_flag' => $this->getOption('header_flag'), 'capture_day' => $this->getOption('capture_day'), 'capture_mode' => $this->getOption('capture_mode'), 'bgcolor' => $this->getOption('bgcolor'), 'block_align' => $this->getOption('block_align'), 'block_order' => $this->getOption('block_order'), 'textcolor' => $this->getOption('textcolor'), 'normal_return_logo' => $this->getOption('normal_return_logo'), 'cancel_return_logo' => $this->getOption('cancel_return_logo'), 'submit_logo' => $this->getOption('submit_logo'), 'logo_id' => $this->getOption('logo_id'), 'logo_id2' => $this->getOption('logo_id2'), 'advert' => $this->getOption('advert'), 'background_id' => $this->getOption('background_id'), 'templatefile' => $this->getOption('templatefile'), 'amount' => $this->getAmount($order->getTotalInc(), $order->getCurrency()->getLabel()), 'currency_code' => $this->getCurrencyCode($order->getCurrency()->getLabel()), 'transaction_id' => $this->transactionGenerator->generate($order), 'normal_return_url' => $this->router->generate($this->getOption('url_return_ok'), $params, true), 'cancel_return_url' => $this->router->generate($this->getOption('url_return_ko'), $params, true), 'automatic_response_url' => $this->router->generate($this->getOption('url_callback'), $params, true), 'caddie' => 'mon_caddie', 'customer_id' => $order->getCustomer()->getId(), 'customer_email' => $order->getCustomer()->getEmail(), 'customer_ip_address' => '', 'data' => $this->getOption('data'), 'return_context' => '', 'target' => '', 'order_id' => $order->getReference());
     // clean parameters
     $cmdLineOptions = array();
     foreach ($cmdLineParameters as $option => $value) {
         $cmdLineOptions[] = sprintf('%s=%s', $option, $this->encodeString($value));
     }
     $cmd = sprintf('cd %s && %s %s', $this->getOption('base_folder'), $this->getOption('request_command'), join(' ', $cmdLineOptions));
     $this->logger->debug(sprintf('Running command : %s', $cmd));
     $process = new Process($cmd);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('Error %d when executing Scellius command: "%s".', $process->getExitCode(), trim($process->getErrorOutput())));
     }
     //sortie de la fonction : $result=!code!error!buffer!
     //    - code=0  : la fonction génère une page html contenue dans la variable buffer
     //    - code=-1 : La fonction retourne un message d'erreur dans la variable error
     $data = explode("!", $process->getOutput());
     if (count($data) != 5) {
         throw new \RuntimeException('Invalid data count');
     }
     if ($data[1] == 0) {
         $scellius = array('valid' => true, 'content' => $data[3]);
     } else {
         $scellius = array('valid' => false, 'content' => $data[2]);
     }
     return $this->templating->renderResponse($this->getOption('template'), array('order' => $order, 'scellius' => $scellius, 'debug' => $this->debug, 'parameters' => $cmdLineParameters));
 }