当前位置: 首页>>代码示例>>PHP>>正文


PHP Random::getUniqueHash方法代码示例

本文整理汇总了PHP中Magento\Framework\Math\Random::getUniqueHash方法的典型用法代码示例。如果您正苦于以下问题:PHP Random::getUniqueHash方法的具体用法?PHP Random::getUniqueHash怎么用?PHP Random::getUniqueHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Math\Random的用法示例。


在下文中一共展示了Random::getUniqueHash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postRequest

 /**
  * Post request into gateway
  *
  * @param DataObject $request
  * @param ConfigInterface $config
  *
  * @return DataObject
  * @throws \Zend_Http_Client_Exception
  */
 public function postRequest(DataObject $request, ConfigInterface $config)
 {
     $result = new DataObject();
     $clientConfig = ['maxredirects' => 5, 'timeout' => 30, 'verifypeer' => $config->getValue('verify_peer')];
     if ($config->getValue('use_proxy')) {
         $clientConfig['proxy'] = $config->getValue('proxy_host') . ':' . $config->getValue('proxy_port');
         $clientConfig['httpproxytunnel'] = true;
         $clientConfig['proxytype'] = CURLPROXY_HTTP;
     }
     /** @var ZendClient $client */
     $client = $this->httpClientFactory->create();
     $client->setUri((bool) $config->getValue('sandbox_flag') ? $config->getValue('transaction_url_test_mode') : $config->getValue('transaction_url'));
     $client->setConfig($clientConfig);
     $client->setMethod(\Zend_Http_Client::POST);
     $client->setParameterPost($request->getData());
     $client->setHeaders(['X-VPS-VIT-CLIENT-CERTIFICATION-ID' => '33baf5893fc2123d8b191d2d011b7fdc', 'X-VPS-Request-ID' => $this->mathRandom->getUniqueHash(), 'X-VPS-CLIENT-TIMEOUT' => 45]);
     $client->setUrlEncodeBody(false);
     try {
         $response = $client->request();
         $responseArray = [];
         parse_str(strstr($response->getBody(), 'RESULT'), $responseArray);
         $result->setData(array_change_key_case($responseArray, CASE_LOWER));
         $result->setData('result_code', $result->getData('result'));
     } catch (\Zend_Http_Client_Exception $e) {
         $result->addData(['response_code' => -1, 'response_reason_code' => $e->getCode(), 'response_reason_text' => $e->getMessage()]);
         throw $e;
     } finally {
         $this->logger->debug(['request' => $request->getData(), 'result' => $result->getData()], (array) $config->getValue('getDebugReplacePrivateDataKeys'), (bool) $config->getValue('debug'));
     }
     return $result;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:40,代码来源:Gateway.php

示例2: encodeArrayFieldValue

 /**
  * Encode value to be used in \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
  *
  * @param array $value
  * @return array
  */
 protected function encodeArrayFieldValue(array $value)
 {
     $result = [];
     foreach ($value as $country => $creditCardType) {
         $resultId = $this->mathRandom->getUniqueHash('_');
         $result[$resultId] = ['country_id' => $country, 'cc_types' => $creditCardType];
     }
     return $result;
 }
开发者ID:nja78,项目名称:magento2,代码行数:15,代码来源:Countrycreditcard.php

示例3: _toHtml

 /**
  * Render the chooser HTML
  * Target element should be set.
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (empty($this->_targetElementId)) {
         return '';
     }
     $idSuffix = $this->mathRandom->getUniqueHash();
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $dateFields = array('from' => __('From'), 'to' => __('To'));
     foreach ($dateFields as $key => $label) {
         $form->addField("{$key}_{$idSuffix}", 'date', array('format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT, 'label' => $label, 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'onchange' => "dateTimeChoose_{$idSuffix}()", 'value' => $this->_rangeValues[$key]));
     }
     return $form->toHtml() . "<script type=\"text/javascript\">\n            dateTimeChoose_{$idSuffix} = function() {\n                \$('{$this->_targetElementId}').value = " . "\$('from_{$idSuffix}').value + '{$this->_rangeDelimiter}' + \$('to_{$idSuffix}').value;\n            };\n            </script>";
 }
开发者ID:aiesh,项目名称:magento2,代码行数:20,代码来源:Daterange.php

示例4: generateLayoutUpdateXml

 /**
  * Generate layout update xml
  *
  * @param string $container
  * @param string $templatePath
  * @return string
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function generateLayoutUpdateXml($container, $templatePath = '')
 {
     $templateFilename = $this->_viewFileSystem->getTemplateFileName($templatePath, ['area' => $this->getArea(), 'themeId' => $this->getThemeId(), 'module' => \Magento\Framework\View\Element\AbstractBlock::extractModuleName($this->getType())]);
     if (!$this->getId() && !$this->isCompleteToCreate() || $templatePath && !is_readable($templateFilename)) {
         return '';
     }
     $parameters = $this->getWidgetParameters();
     $xml = '<body><referenceContainer name="' . $container . '">';
     $template = '';
     if (isset($parameters['template'])) {
         unset($parameters['template']);
     }
     if ($templatePath) {
         $template = ' template="' . $templatePath . '"';
     }
     $hash = $this->mathRandom->getUniqueHash();
     $xml .= '<block class="' . $this->getType() . '" name="' . $hash . '"' . $template . '>';
     foreach ($parameters as $name => $value) {
         if ($name == 'conditions') {
             $name = 'conditions_encoded';
             $value = $this->conditionsHelper->encode($value);
         } elseif (is_array($value)) {
             $value = implode(',', $value);
         }
         if ($name && strlen((string) $value)) {
             $xml .= '<action method="setData">' . '<argument name="name" xsi:type="string">' . $name . '</argument>' . '<argument name="value" xsi:type="string">' . $this->_escaper->escapeHtml($value) . '</argument>' . '</action>';
         }
     }
     $xml .= '</block></referenceContainer></body>';
     return $xml;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:40,代码来源:Instance.php

示例5: encodeArrayFieldValue

 /**
  * Encode value to be used in \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
  *
  * @param array $value
  * @return array
  */
 protected function encodeArrayFieldValue(array $value)
 {
     $result = [];
     // first combine the ccTypes together
     $list = [];
     foreach ($value as $ccType => $items) {
         // sort on amount
         ksort($items);
         foreach ($items as $amount => $installment) {
             if (!isset($list[$installment][$amount])) {
                 $list[$installment][$amount] = [$ccType];
             } else {
                 $ccTypes = $list[$installment][$amount];
                 $ccTypes[] = $ccType;
                 $list[$installment][$amount] = $ccTypes;
             }
         }
     }
     // loop through combined ccTypes configuration and pre fill the items
     foreach ($list as $installment => $amounts) {
         foreach ($amounts as $amount => $ccTypes) {
             $resultId = $this->mathRandom->getUniqueHash('_');
             $result[$resultId] = ['amount' => $amount, 'cc_types' => $ccTypes, 'installments' => $installment];
         }
     }
     return $result;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:33,代码来源:Installments.php

示例6: _beforeToHtml

 /**
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 protected function _beforeToHtml()
 {
     $result = parent::_beforeToHtml();
     /** @var \Magento\Paypal\Model\Config $config */
     $config = $this->_paypalConfigFactory->create();
     $config->setMethod($this->_paymentMethodCode);
     $isInCatalog = $this->getIsInCatalogProduct();
     if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) {
         $this->_shouldRender = false;
         return $result;
     }
     $quote = $isInCatalog || !$this->_checkoutSession ? null : $this->_checkoutSession->getQuote();
     // set misc data
     $this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_'))->setCheckoutUrl($this->getUrl($this->_startAction));
     // use static image if in catalog
     if ($isInCatalog || null === $quote) {
         $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl($this->_localeResolver->getLocale()));
     } else {
         /**@todo refactor checkout model. Move getCheckoutShortcutImageUrl to helper or separate model */
         $parameters = ['params' => ['quote' => $quote, 'config' => $config]];
         $checkoutModel = $this->_checkoutFactory->create($this->_checkoutType, $parameters);
         $this->setImageUrl($checkoutModel->getCheckoutShortcutImageUrl());
     }
     // ask whether to create a billing agreement
     $customerId = $this->currentCustomer->getCustomerId();
     // potential issue for caching
     if ($this->_paypalData->shouldAskToCreateBillingAgreement($config, $customerId)) {
         $this->setConfirmationUrl($this->getUrl($this->_startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1]));
         $this->setConfirmationMessage(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'));
     }
     return $result;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:Shortcut.php

示例7: requestToken

 /**
  * Get the Secure Token from Paypal for TR
  *
  * @param Quote $quote
  *
  * @return DataObject
  * @throws \Exception
  */
 public function requestToken(Quote $quote)
 {
     $request = $this->transparent->buildBasicRequest();
     $request->setTrxtype(Payflowpro::TRXTYPE_AUTH_ONLY);
     $request->setVerbosity('HIGH');
     $request->setAmt(0);
     $request->setCreatesecuretoken('Y');
     $request->setSecuretokenid($this->mathRandom->getUniqueHash());
     $request->setReturnurl($this->url->getUrl('paypal/transparent/response'));
     $request->setErrorurl($this->url->getUrl('paypal/transparent/response'));
     $request->setCancelurl($this->url->getUrl('paypal/transparent/cancel'));
     $request->setDisablereceipt('TRUE');
     $request->setSilenttran('TRUE');
     $this->transparent->fillCustomerContacts($quote, $request);
     $result = $this->transparent->postRequest($request, $this->transparent->getConfig());
     return $result;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:SecureToken.php

示例8: encodeArrayFieldValue

 /**
  * Encode value to be used in \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
  *
  * @param array $value
  * @return array
  */
 protected function encodeArrayFieldValue(array $value)
 {
     $result = [];
     foreach ($value as $groupId => $qty) {
         $resultId = $this->mathRandom->getUniqueHash('_');
         $result[$resultId] = ['customer_group_id' => $groupId, 'min_sale_qty' => $this->fixQty($qty)];
     }
     return $result;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Minsaleqty.php

示例9: _toHtml

 /**
  * @return string
  */
 protected function _toHtml()
 {
     $standard = $this->_paypalStandardFactory->create();
     $form = $this->_formFactory->create();
     $form->setAction($standard->getConfig()->getPaypalUrl())->setId('paypal_standard_checkout')->setName('paypal_standard_checkout')->setMethod('POST')->setUseContainer(true);
     foreach ($standard->getStandardCheckoutFormFields() as $field => $value) {
         $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
     }
     $idSuffix = $this->mathRandom->getUniqueHash();
     $submitButton = $this->_elementFactory->create('submit', array('data' => array('value' => __('Click here if you are not redirected within 10 seconds.'))));
     $id = "submit_to_paypal_button_{$idSuffix}";
     $submitButton->setId($id);
     $form->addElement($submitButton);
     $html = '<html><body>';
     $html .= __('You will be redirected to the PayPal website in a few seconds.');
     $html .= $form->toHtml();
     $html .= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();';
     $html .= '</script></body></html>';
     return $html;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:23,代码来源:Redirect.php

示例10: getHtml

 /**
  * @return string
  */
 public function getHtml()
 {
     $htmlId = $this->mathRandom->getUniqueHash($this->_getHtmlId());
     $format = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
     $html = '<div class="range" id="' . $htmlId . '_range"><div class="range-line date">' . '<input type="text" name="' . $this->_getHtmlName() . '[from]" id="' . $htmlId . '_from"' . ' value="' . $this->getEscapedValue('from') . '" class="admin__control-text input-text no-changes" placeholder="' . __('From') . '" ' . $this->getUiId('filter', $this->_getHtmlName(), 'from') . '/>' . '</div>';
     $html .= '<div class="range-line date">' . '<input type="text" name="' . $this->_getHtmlName() . '[to]" id="' . $htmlId . '_to"' . ' value="' . $this->getEscapedValue('to') . '" class="input-text admin__control-text no-changes" placeholder="' . __('To') . '" ' . $this->getUiId('filter', $this->_getHtmlName(), 'to') . '/>' . '</div></div>';
     $html .= '<input type="hidden" name="' . $this->_getHtmlName() . '[locale]"' . ' value="' . $this->localeResolver->getLocale() . '"/>';
     $html .= '<script>
         require(["jquery", "mage/calendar"], function($){
             $("#' . $htmlId . '_range").dateRange({
                 dateFormat: "' . $format . '",
                     buttonText: "' . $this->escapeHtml(__('Date selector')) . '",
                 from: {
                     id: "' . $htmlId . '_from"
                 },
                 to: {
                     id: "' . $htmlId . '_to"
                 }
             })
         });
     </script>';
     return $html;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:Date.php

示例11: getHtml

 /**
  * @return string
  */
 public function getHtml()
 {
     $htmlId = $this->mathRandom->getUniqueHash($this->_getHtmlId());
     $format = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
     $html = '<div class="range" id="' . $htmlId . '_range"><div class="range-line date">' . '<input type="text" name="' . $this->_getHtmlName() . '[from]" id="' . $htmlId . '_from"' . ' value="' . $this->getEscapedValue('from') . '" class="input-text no-changes" placeholder="' . __('From') . '" ' . $this->getUiId('filter', $this->_getHtmlName(), 'from') . '/>' . '</div>';
     $html .= '<div class="range-line date">' . '<input type="text" name="' . $this->_getHtmlName() . '[to]" id="' . $htmlId . '_to"' . ' value="' . $this->getEscapedValue('to') . '" class="input-text no-changes" placeholder="' . __('To') . '" ' . $this->getUiId('filter', $this->_getHtmlName(), 'to') . '/>' . '</div></div>';
     $html .= '<input type="hidden" name="' . $this->_getHtmlName() . '[locale]"' . ' value="' . $this->_localeResolver->getLocaleCode() . '"/>';
     $html .= '<script type="text/javascript">
         require(["jquery", "mage/calendar"], function($){
             $("#' . $htmlId . '_range").dateRange({
                 dateFormat: "' . $format . '",
                 buttonImage: "' . $this->getViewFileUrl('images/grid-cal.gif') . '",
                     buttonText: "' . $this->escapeHtml(__('Date selector')) . '",
                 from: {
                     id: "' . $htmlId . '_from"
                 },
                 to: {
                     id: "' . $htmlId . '_to"
                 }
             })
         });
     </script>';
     return $html;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:27,代码来源:Date.php

示例12: _beforeToHtml

 /**
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 protected function _beforeToHtml()
 {
     $result = parent::_beforeToHtml();
     $isInCatalog = $this->getIsInCatalogProduct();
     if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) {
         $this->_shouldRender = false;
         return $result;
     }
     $quote = $isInCatalog || !$this->_checkoutSession ? null : $this->_checkoutSession->getQuote();
     // set misc data
     $this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_'))->setCheckoutUrl($this->getUrl($this->_startAction));
     // use static image if in catalog
     if ($isInCatalog || null === $quote) {
         $this->setImageUrl($this->config->getExpressCheckoutShortcutImageUrl($this->_localeResolver->getLocale()));
     } else {
         /**@todo refactor checkout model. Move getCheckoutShortcutImageUrl to helper or separate model */
         $parameters = ['params' => ['quote' => $quote, 'config' => $this->config]];
         $checkoutModel = $this->_checkoutFactory->create($this->_checkoutType, $parameters);
         $this->setImageUrl($checkoutModel->getCheckoutShortcutImageUrl());
     }
     return $result;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:Shortcut.php

示例13: _buildTokenRequest

 /**
  * Build request for getting token
  *
  * @param \Magento\Sales\Model\Order\Payment $payment
  * @return \Magento\Framework\DataObject
  */
 protected function _buildTokenRequest(\Magento\Sales\Model\Order\Payment $payment)
 {
     $request = $this->buildBasicRequest();
     $request->setCreatesecuretoken('Y')->setSecuretokenid($this->mathRandom->getUniqueHash())->setTrxtype($this->_getTrxTokenType());
     $order = $payment->getOrder();
     $request->setAmt(sprintf('%.2F', $order->getBaseTotalDue()))->setCurrency($order->getBaseCurrencyCode());
     $this->addRequestOrderInfo($request, $order);
     $request = $this->fillCustomerContacts($order, $request);
     //pass store Id to request
     $request->setData('USER1', $order->getStoreId());
     $request->setData('USER2', $this->_getSecureSilentPostHash($payment));
     return $request;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:Payflowlink.php

示例14: _generateRandomCode

 /**
  * Generates random code for subscription confirmation
  *
  * @return string
  */
 protected function _generateRandomCode()
 {
     return $this->mathRandom->getUniqueHash();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:9,代码来源:Subscriber.php

示例15: generateResetPasswordLinkToken

 /**
  * Generate unique token for reset password confirmation link
  *
  * @return string
  */
 public function generateResetPasswordLinkToken()
 {
     return $this->mathRandom->getUniqueHash();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:9,代码来源:Data.php


注:本文中的Magento\Framework\Math\Random::getUniqueHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。