123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Sales\Block\Order\Info\Buttons;
- /**
- * Block of links in Order view page
- *
- * @api
- * @since 100.0.2
- */
- class Rss extends \Magento\Framework\View\Element\Template
- {
- /**
- * @var string
- */
- protected $_template = 'Magento_Sales::order/info/buttons/rss.phtml';
- /**
- * @var \Magento\Sales\Model\OrderFactory
- */
- protected $orderFactory;
- /**
- * @var \Magento\Framework\App\Rss\UrlBuilderInterface
- */
- protected $rssUrlBuilder;
- /**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Sales\Model\OrderFactory $orderFactory
- * @param \Magento\Framework\App\Rss\UrlBuilderInterface $rssUrlBuilder
- * @param array $data
- */
- public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Sales\Model\OrderFactory $orderFactory,
- \Magento\Framework\App\Rss\UrlBuilderInterface $rssUrlBuilder,
- array $data = []
- ) {
- $this->orderFactory = $orderFactory;
- $this->rssUrlBuilder = $rssUrlBuilder;
- parent::__construct($context, $data);
- }
- /**
- * Get link url.
- *
- * @return string
- */
- public function getLink()
- {
- return $this->rssUrlBuilder->getUrl($this->getLinkParams());
- }
- /**
- * Get translatable label for url.
- *
- * @return \Magento\Framework\Phrase
- */
- public function getLabel()
- {
- return __('Subscribe to Order Status');
- }
- /**
- * Check whether status notification is allowed
- *
- * @return bool
- */
- public function isRssAllowed()
- {
- return $this->_scopeConfig->isSetFlag(
- 'rss/order/status',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
- );
- }
- /**
- * Retrieve order status url key
- *
- * @param \Magento\Sales\Model\Order $order
- * @return string
- */
- protected function getUrlKey($order)
- {
- $data = [
- 'order_id' => $order->getId(),
- 'increment_id' => $order->getIncrementId(),
- 'customer_id' => $order->getCustomerId(),
- ];
- return base64_encode(json_encode($data));
- }
- /**
- * Get type, secure and query params for link.
- *
- * @return array
- * @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
- */
- protected function getLinkParams()
- {
- $order = $this->orderFactory->create()->load($this->_request->getParam('order_id'));
- return [
- 'type' => 'order_status',
- '_secure' => true,
- '_query' => ['data' => $this->getUrlKey($order)]
- ];
- }
- }
|