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


PHP Data::urlEncode方法代码示例

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


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

示例1: getSwitchCurrencyUrl

 /**
  * Retrieve switch currency url
  *
  * @param array $params Additional url params
  * @return string
  */
 public function getSwitchCurrencyUrl($params = array())
 {
     $params = is_array($params) ? $params : array();
     if ($this->_getRequest()->getAlias('rewrite_request_path')) {
         $url = $this->_storeManager->getStore()->getBaseUrl() . $this->_getRequest()->getAlias('rewrite_request_path');
     } else {
         $url = $this->_urlBuilder->getCurrentUrl();
     }
     $params[\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED] = $this->_coreData->urlEncode($url);
     return $this->_getUrl('directory/currency/switch', $params);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:17,代码来源:Url.php

示例2: setUp

 protected function setUp()
 {
     $this->_fixtureCustomerId = 1;
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_customerSession = $this->_objectManager->create('Magento\\Customer\\Model\\Session');
     $this->_coreData = $this->_objectManager->create('Magento\\Core\\Helper\\Data');
     $this->_contextHelper = $this->_objectManager->create('Magento\\Framework\\App\\Helper\\Context');
     $request = $this->_contextHelper->getRequest();
     $request->setParam('data', $this->_coreData->urlEncode($this->_fixtureCustomerId));
     $this->_wishlistHelper = $this->_objectManager->create('Magento\\Rss\\Helper\\WishlistRss', ['context' => $this->_contextHelper, 'customerSession' => $this->_customerSession]);
     $this->_customerSession->loginById($this->_fixtureCustomerId);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:12,代码来源:WishlistRssTest.php

示例3: _getTrackingUrl

 /**
  * Retrieve tracking url with params
  *
  * @param  string $key
  * @param  \Magento\Sales\Model\Order|\Magento\Sales\Model\Order\Shipment|\Magento\Sales\Model\Order\Shipment\Track $model
  * @param  string $method Optional - method of a model to get id
  * @return string
  */
 protected function _getTrackingUrl($key, $model, $method = 'getId')
 {
     $urlPart = "{$key}:{$model->{$method}()}:{$model->getProtectCode()}";
     $param = array('hash' => $this->_coreData->urlEncode($urlPart));
     $storeModel = $this->_storeManager->getStore($model->getStoreId());
     return $storeModel->getUrl('shipping/tracking/popup', $param);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Data.php

示例4: getRssUrl

 /**
  * Retrieve RSS URL
  *
  * @param int|string|null $wishlistId
  * @return string
  */
 public function getRssUrl($wishlistId = null)
 {
     $customer = $this->_getCurrentCustomer();
     if ($customer) {
         $key = $customer->getId() . ',' . $customer->getEmail();
         $params = array('data' => $this->_coreData->urlEncode($key), '_secure' => false);
     }
     if ($wishlistId) {
         $params['wishlist_id'] = $wishlistId;
     }
     return $this->_getUrl('rss/index/wishlist', $params);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:18,代码来源:Data.php

示例5: outputValue

 /**
  * {@inheritdoc}
  */
 public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
 {
     $output = '';
     if ($this->_value) {
         switch ($format) {
             case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_JSON:
                 $output = array('value' => $this->_value, 'url_key' => $this->_coreData->urlEncode($this->_value));
                 break;
         }
     }
     return $output;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:File.php

示例6: testCustomerTitle

 /**
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php
  * @magentoAppArea frontend
  */
 public function testCustomerTitle()
 {
     $fixtureCustomerId = 1;
     $this->_customerSession->loginById($fixtureCustomerId);
     /** @var \Magento\Wishlist\Model\Wishlist $wishlist */
     $wishlist = $this->_objectManager->create('Magento\\Wishlist\\Model\\Wishlist')->loadByCustomerId($fixtureCustomerId);
     /** @var \Magento\Framework\App\Helper\Context $contextHelper */
     $contextHelper = $this->_objectManager->create('Magento\\Framework\\App\\Helper\\Context');
     $wishlistHelper = $this->_objectManager->create('Magento\\Wishlist\\Helper\\Rss', ['context' => $contextHelper, 'customerSession' => $this->_customerSession]);
     /** @var \Magento\Catalog\Block\Product\Context $context */
     $contextBlock = $this->_objectManager->create('Magento\\Wishlist\\Block\\Context', ['request' => $contextHelper->getRequest(), 'wishlistHelper' => $wishlistHelper]);
     /** @var \Magento\Framework\App\Request\Http $request */
     $request = $contextHelper->getRequest();
     $request->setParam('wishlist_id', $wishlist->getId());
     $request->setParam('data', $this->_coreData->urlEncode($fixtureCustomerId));
     /** @var \Magento\Wishlist\Block\Rss $block */
     $block = $this->_objectManager->create('Magento\\Wishlist\\Block\\Rss', ['context' => $contextBlock]);
     /** @var \Magento\Framework\Escaper $escaper */
     $escaper = $this->_objectManager->create('Magento\\Framework\\Escaper');
     $expectedSting = '%A' . __("<title><![CDATA[%1 %2's Wishlist]]></title>", $escaper->escapeHtml($this->_customerSession->getCustomerDataObject()->getFirstname()), $escaper->escapeHtml($this->_customerSession->getCustomerDataObject()->getLastname())) . '%A';
     $this->assertStringMatchesFormat($expectedSting, $block->toHtml());
 }
开发者ID:,项目名称:,代码行数:27,代码来源:

示例7: outputValue

 /**
  * Return formated attribute value from entity model
  *
  * @param string $format
  * @return string|array
  */
 public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
 {
     $output = '';
     $value = $this->getEntity()->getData($this->getAttribute()->getAttributeCode());
     if ($value) {
         switch ($format) {
             case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON:
                 $output = array('value' => $value, 'url_key' => $this->_coreData->urlEncode($value));
                 break;
         }
     }
     return $output;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:File.php

示例8: getAddToCartUrl

 /**
  * Retrieve url for direct adding product to cart
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param array $additional
  * @return string
  */
 public function getAddToCartUrl($product, $additional = array())
 {
     if ($this->hasCustomAddToCartUrl()) {
         return $this->getCustomAddToCartUrl();
     }
     if ($this->getRequest()->getParam('wishlist_next')) {
         $additional['wishlist_next'] = 1;
     }
     $addUrlKey = \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED;
     $addUrlValue = $this->_urlBuilder->getUrl('*/*/*', array('_use_rewrite' => true, '_current' => true));
     $additional[$addUrlKey] = $this->_coreData->urlEncode($addUrlValue);
     return $this->_cartHelper->getAddUrl($product, $additional);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:20,代码来源:View.php

示例9: getAddUrl

 /**
  * Retrieve url for add product to cart
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param array $additional
  * @return  string
  */
 public function getAddUrl($product, $additional = array())
 {
     $continueUrl = $this->_coreData->urlEncode($this->_urlBuilder->getCurrentUrl());
     $urlParamName = \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED;
     $routeParams = array($urlParamName => $continueUrl, 'product' => $product->getEntityId());
     if (!empty($additional)) {
         $routeParams = array_merge($routeParams, $additional);
     }
     if ($product->hasUrlDataObject()) {
         $routeParams['_scope'] = $product->getUrlDataObject()->getStoreId();
         $routeParams['_scope_to_url'] = true;
     }
     if ($this->_getRequest()->getRouteName() == 'checkout' && $this->_getRequest()->getControllerName() == 'cart') {
         $routeParams['in_cart'] = 1;
     }
     return $this->_getUrl('checkout/cart/add', $routeParams);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:24,代码来源:Cart.php

示例10: getImageHtmlDeclaration

 /**
  * Prepare Image insertion declaration for Wysiwyg or textarea(as_is mode)
  *
  * @param string $filename Filename transferred via Ajax
  * @param bool $renderAsTag Leave image HTML as is or transform it to controller directive
  * @return string
  */
 public function getImageHtmlDeclaration($filename, $renderAsTag = false)
 {
     $fileurl = $this->getCurrentUrl() . $filename;
     $mediaUrl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
     $mediaPath = str_replace($mediaUrl, '', $fileurl);
     $directive = sprintf('{{media url="%s"}}', $mediaPath);
     if ($renderAsTag) {
         $html = sprintf('<img src="%s" alt="" />', $this->isUsingStaticUrlsAllowed() ? $fileurl : $directive);
     } else {
         if ($this->isUsingStaticUrlsAllowed()) {
             $html = $fileurl;
             // $mediaPath;
         } else {
             $directive = $this->_coreData->urlEncode($directive);
             $html = $this->_backendData->getUrl('cms/wysiwyg/directive', array('___directive' => $directive));
         }
     }
     return $html;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:26,代码来源:Images.php

示例11: _construct

 /**
  * Initialize review form
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $data = $this->_reviewSession->getFormData(true);
     $data = new \Magento\Framework\Object((array) $data);
     // add logged in customer name as nickname
     if (!$data->getNickname()) {
         $customer = $this->_customerSession->getCustomerDataObject();
         if ($customer && $customer->getId()) {
             $data->setNickname($customer->getFirstname());
         }
     }
     $this->setAllowWriteReviewFlag($this->httpContext->getValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH) || $this->_reviewData->getIsGuestAllowToWrite());
     if (!$this->getAllowWriteReviewFlag()) {
         $queryParam = $this->_coreData->urlEncode($this->getUrl('*/*/*', array('_current' => true)) . '#review-form');
         $this->setLoginLink($this->getUrl('customer/account/login/', array(\Magento\Customer\Helper\Data::REFERER_QUERY_PARAM_NAME => $queryParam)));
     }
     $this->setTemplate('form.phtml')->assign('data', $data)->assign('messages', $this->messageManager->getMessages(true));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:24,代码来源:Form.php

示例12: getLoginUrlParams

 /**
  * Retrieve parameters of customer login url
  *
  * @return array
  */
 public function getLoginUrlParams()
 {
     $params = array();
     $referer = $this->_getRequest()->getParam(self::REFERER_QUERY_PARAM_NAME);
     if (!$referer && !$this->_scopeConfig->isSetFlag(self::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, \Magento\Store\Model\ScopeInterface::SCOPE_STORE) && !$this->_customerSession->getNoReferer()) {
         $referer = $this->_getUrl('*/*/*', array('_current' => true, '_use_rewrite' => true));
         $referer = $this->_coreData->urlEncode($referer);
     }
     if ($referer) {
         $params = array(self::REFERER_QUERY_PARAM_NAME => $referer);
     }
     return $params;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Data.php

示例13: encodeWidgetsToQuery

 /**
  * Encode list of widget types into query param
  *
  * @param string[]|string $widgets List of widgets
  * @return string Query param value
  */
 public function encodeWidgetsToQuery($widgets)
 {
     $widgets = is_array($widgets) ? $widgets : array($widgets);
     $param = implode(',', $widgets);
     return $this->_coreHelper->urlEncode($param);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:Config.php

示例14: getAddToWishlistParams

 /**
  * Get add to wishlist params
  *
  * @param Product $product
  * @return string
  */
 public function getAddToWishlistParams($product)
 {
     $continueUrl = $this->_coreData->urlEncode($this->getUrl('customer/account'));
     $urlParamName = Action::PARAM_NAME_URL_ENCODED;
     $continueUrlParams = array($urlParamName => $continueUrl);
     return $this->_wishlistHelper->getAddParams($product, $continueUrlParams);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:13,代码来源:ListCompare.php


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