示例#1
0
 /**
  * Renders grid column
  *
  * @param   \Magento\Framework\DataObject $row
  * @return  string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     $readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' . __('Read Details') . '</a>' : '';
     $markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl('*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()]) . '">' . __('Mark as Read') . '</a>' : '';
     $encodedUrl = $this->_urlHelper->getEncodedUrl();
     return sprintf('%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>', $readDetailsHtml, $markAsReadHtml, $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
 }
示例#2
0
 /**
  * get data for post by javascript in format acceptable to $.mage.dataPost widget
  *
  * @param string $url
  * @param array $data
  * @return string
  */
 public function getPostData($url, array $data = [])
 {
     if (!isset($data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED])) {
         $data[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl();
     }
     return json_encode(['action' => $url, 'data' => $data]);
 }
 /**
  * Set redirect url for store view based on request path info
  *
  * @param \Magento\Store\Block\Switcher $switcher
  * @param \Magento\Store\Model\Store $store
  * @param array $data
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeGetTargetStorePostData(\Magento\Store\Block\Switcher $switcher, \Magento\Store\Model\Store $store, $data = [])
 {
     $urlRewrite = $this->urlFinder->findOneByData([UrlRewrite::TARGET_PATH => $this->trimSlashInPath($this->request->getPathInfo()), UrlRewrite::STORE_ID => $store->getId()]);
     if ($urlRewrite) {
         $data[ActionInterface::PARAM_NAME_URL_ENCODED] = $this->urlHelper->getEncodedUrl($this->trimSlashInPath($this->urlBuilder->getUrl($urlRewrite->getRequestPath())));
     }
     return [$store, $data];
 }
示例#4
0
 /**
  * Renders grid column
  *
  * @param   \Magento\Framework\DataObject $row
  * @return  string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     $encodedUrl = $this->_urlHelper->getEncodedUrl();
     if (!$row->getIsRead()) {
         return sprintf('<a href="%s">%s</a> | <a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $this->getUrl('*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()]), __('Mark as Read'), $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
     } else {
         return sprintf('<a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
     }
     return parent::render($row);
 }
示例#5
0
 /**
  * Retrieve create new account url
  *
  * @return string
  */
 public function getCreateAccountUrl()
 {
     $url = $this->getData('create_account_url');
     if ($url === null) {
         $url = $this->_customerUrl->getRegisterUrl();
     }
     if ($this->checkoutData->isContextCheckout()) {
         $url = $this->coreUrl->addRequestParam($url, ['context' => 'checkout']);
     }
     return $url;
 }
示例#6
0
 /**
  * Set auth url
  *
  * @param string $key
  * @param string $url
  * @return $this
  */
 protected function _setAuthUrl($key, $url)
 {
     $url = $this->_coreUrl->removeRequestParam($url, $this->sidResolver->getSessionIdQueryParam($this));
     // Add correct session ID to URL if needed
     $url = $this->_createUrl()->getRebuiltUrl($url);
     return $this->storage->setData($key, $url);
 }
示例#7
0
 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Registry $coreRegistry
  * @param \Magento\Framework\View\LayoutInterface $layout
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\LayoutInterface $layout)
 {
     $this->_coreRegistry = $coreRegistry;
     $this->_layout = $layout;
     $this->_storeManager = $storeManager;
     parent::__construct($context);
 }
示例#8
0
 /**
  * Get post parameters
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return string
  */
 public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
 {
     $url = $this->getAddToCartUrl($product);
     return ['action' => $url, 'data' => ['product' => $product->getEntityId(), \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url)]];
 }
示例#9
0
 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Catalog\Model\Session $catalogSession
  * @param \Magento\Framework\View\Asset\Repository $assetRepo
  * @param \Magento\Framework\Registry $coreRegistry
  * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig
  * @param array $reindexPriceIndexerData
  * @param array $reindexProductCategoryIndexerData
  * @param ProductRepositoryInterface $productRepository
  * @param CategoryRepositoryInterface $categoryRepository
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\Registry $coreRegistry, \Magento\Catalog\Model\Attribute\Config $attributeConfig, $reindexPriceIndexerData, $reindexProductCategoryIndexerData, ProductRepositoryInterface $productRepository, CategoryRepositoryInterface $categoryRepository)
 {
     $this->_catalogSession = $catalogSession;
     $this->_attributeConfig = $attributeConfig;
     $this->_coreRegistry = $coreRegistry;
     $this->_assetRepo = $assetRepo;
     $this->_reindexPriceIndexerData = $reindexPriceIndexerData;
     $this->productRepository = $productRepository;
     $this->categoryRepository = $categoryRepository;
     $this->_reindexProductCategoryIndexerData = $reindexProductCategoryIndexerData;
     $this->_storeManager = $storeManager;
     parent::__construct($context);
 }
示例#10
0
 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  * @param \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory
  * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility
  * @param \Magento\Customer\Model\Visitor $customerVisitor
  * @param \Magento\Customer\Model\Session $customerSession
  * @param \Magento\Catalog\Model\Session $catalogSession
  * @param \Magento\Framework\Data\Form\FormKey $formKey
  * @param \Magento\Wishlist\Helper\Data $wishlistHelper
  * @param \Magento\Framework\Data\Helper\PostHelper $postHelper
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory $itemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\Customer\Model\Visitor $customerVisitor, \Magento\Customer\Model\Session $customerSession, \Magento\Catalog\Model\Session $catalogSession, \Magento\Framework\Data\Form\FormKey $formKey, \Magento\Wishlist\Helper\Data $wishlistHelper, \Magento\Framework\Data\Helper\PostHelper $postHelper)
 {
     $this->_itemCollectionFactory = $itemCollectionFactory;
     $this->_catalogProductVisibility = $catalogProductVisibility;
     $this->_customerVisitor = $customerVisitor;
     $this->_customerSession = $customerSession;
     $this->_catalogSession = $catalogSession;
     $this->_formKey = $formKey;
     $this->_wishlistHelper = $wishlistHelper;
     $this->postHelper = $postHelper;
     $this->_storeManager = $storeManager;
     parent::__construct($context);
 }
示例#11
0
 public function testGetEncodedUrl()
 {
     $this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MS8,', $this->_helper->getEncodedUrl());
     $this->assertEquals('aHR0cDovL2V4YW1wbGUuY29tLw,,', $this->_helper->getEncodedUrl('http://example.com/'));
 }
示例#12
0
文件: Cart.php 项目: nja78/magento2
 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Checkout\Model\Cart $checkoutCart
  * @param \Magento\Checkout\Model\Session $checkoutSession
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Checkout\Model\Cart $checkoutCart, \Magento\Checkout\Model\Session $checkoutSession)
 {
     $this->_checkoutCart = $checkoutCart;
     $this->_checkoutSession = $checkoutSession;
     parent::__construct($context);
 }
示例#13
0
 /**
  * Prepare current URL for referer
  *
  * @return string
  */
 public function getUrlForReferer()
 {
     return \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED . '/' . $this->_urlHelper->getEncodedUrl();
 }
示例#14
0
 /**
  * Prepare current URL for referer
  *
  * @return string
  */
 public function getUrlForReferer()
 {
     return ActionInterface::PARAM_NAME_URL_ENCODED . '/' . $this->_urlHelper->getEncodedUrl();
 }