protected function setUp() { parent::setUp(); $this->_object = RUtils::translit(); }
<?php namespace php_rutils\doc\examples; use php_rutils\RUtils; require '_begin.php'; //Translify echo RUtils::translit()->translify('Муха - это маленькая птичка'), PHP_EOL; //Result: Muxa - e`to malen`kaya ptichka //Detranslify echo RUtils::translit()->detranslify("Muxa - e`to malen`kaya ptichka"), PHP_EOL; //Result: Муха - это маленькая птичка //Prepare to use in URLs or file/dir name echo RUtils::translit()->slugify('Муха — это маленькая птичка'), PHP_EOL; //Result: muha-eto-malenkaya-ptichka require '_end.php';
public function wizardAction($step, Request $request) { $stepData = $request->getSession()->get('stepData', []); $form = $this->createForm(new InvoiceWizard($step)); $form->handleRequest($request); if ($request->isMethod('GET') && isset($stepData['pbl'])) { $form->get('pbl')->setData($stepData['pbl']); } if ($step == 1) { $request->getSession()->set('stepData', null); $stepData = []; } if (isset($request->get('sportmaster_wizard')['previous'])) { return $this->redirect($this->generateUrl('sportmaster_invoice_number')); } $shipmentData = []; if (isset($stepData['shipment'])) { $shipmentData = $stepData['shipment']; } if ($step == 3) { $report = new InvoicingReport($this->container, $shipmentData); $report->export(); } if ($request->isMethod('POST')) { if ($form->isValid()) { $data = $form->getData(); if ($step == 1) { $env = $this->container->getParameter("kernel.environment"); $host = $env == 'prod' ? 'mowtools.europe.panorg.com' : 'localhost'; $url = 'http://' . $host . '/sportmaster/jsonSO.php'; $client = new GuzzleHttp\Client(['timeout' => 0, 'allow_redirects' => false]); $response = $client->post($url, ['form_params' => ['PBL' => $data['pbl']]]); $result = json_decode((string) $response->getBody(), true); if ($result) { if (!isset($result['error'])) { $stepData = ['pbl' => $data['pbl'], 'shipment' => current($result)]; $ref =& $stepData['shipment']; $ref['VendorName'] = RUtils::translit()->detranslify($ref['VendorName']); $ref['POL'] = isset($ref['POL'][0]) ? $ref['POL'][0] : 'empty'; $ref['percent'] = $ref['ContainerVolume'] != 0 ? round($ref['Volume'] / $ref['ContainerVolume'] * 100, 2) : 'cant calculate'; $ref['currency'] = $this->getDoctrine()->getManager()->getRepository('CoreBundle:CurrencyRate')->getRateByCodeAndDate('USD', new \DateTime('now')); $request->getSession()->set('stepData', $stepData); return $this->redirect($this->generateUrl('sportmaster_invoice_number', ['step' => ++$step])); } else { $form->addError(new FormError($result['error'])); } } else { $form->addError(new FormError("Shipment data PBL = {$data['pbl']} was not found")); } } } } return $this->render('SportmasterBundle:Default:wizard.html.twig', ['form' => $form->createView(), 'step' => $step, 'stepData' => $stepData, 'shipmentData' => $shipmentData]); }
protected function getServiceRuName($serviceName) { $map = ['OceanFreight' => 'О/Ф {pol} – {pod}', 'POMF' => 'СБОР ЗА УПРАВЛЕНИЕ ЗАКАЗОМ', 'Scan' => 'СКАНИРОВАНИЕ', 'Consolidation' => 'КОНСОЛИДАЦИЯ ГРУЗА', 'TelexRelease' => 'ТЕЛЕКС РЕЛИЗ', 'CFSCharges' => 'ПОГРУЗО-РАЗГРУЗОЧНЫЕ РАБОТЫ', 'OTHC' => 'ТЕРМИНАЛЬНАЯ ОБРАБОТКА ГРУЗА В ПОРТУ НАЗНАЧЕНИЯ ({pod})']; if (isset($map[$serviceName])) { $serviceName = $map[$serviceName]; $serviceName = str_replace('{pol}', RUtils::translit()->detranslify($this->shipmentData['POL']), $serviceName); $serviceName = str_replace('{pod}', RUtils::translit()->detranslify($this->shipmentData['POD']), $serviceName); return $serviceName; } return 'unknown'; }