1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- /**
- * Block of links in Order view page
- */
- namespace Magento\Sales\Block\Order\Info;
- use Magento\Customer\Model\Context;
- /**
- * @api
- * @since 100.0.2
- */
- class Buttons extends \Magento\Framework\View\Element\Template
- {
- /**
- * @var string
- */
- protected $_template = 'Magento_Sales::order/info/buttons.phtml';
- /**
- * Core registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $_coreRegistry = null;
- /**
- * @var \Magento\Framework\App\Http\Context
- */
- protected $httpContext;
- /**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\App\Http\Context $httpContext
- * @param array $data
- */
- public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\App\Http\Context $httpContext,
- array $data = []
- ) {
- $this->_coreRegistry = $registry;
- $this->httpContext = $httpContext;
- parent::__construct($context, $data);
- $this->_isScopePrivate = true;
- }
- /**
- * Retrieve current order model instance
- *
- * @return \Magento\Sales\Model\Order
- */
- public function getOrder()
- {
- return $this->_coreRegistry->registry('current_order');
- }
- /**
- * Get url for printing order
- *
- * @param \Magento\Sales\Model\Order $order
- * @return string
- */
- public function getPrintUrl($order)
- {
- if (!$this->httpContext->getValue(Context::CONTEXT_AUTH)) {
- return $this->getUrl('sales/guest/print', ['order_id' => $order->getId()]);
- }
- return $this->getUrl('sales/order/print', ['order_id' => $order->getId()]);
- }
- /**
- * Get url for reorder action
- *
- * @param \Magento\Sales\Model\Order $order
- * @return string
- */
- public function getReorderUrl($order)
- {
- if (!$this->httpContext->getValue(Context::CONTEXT_AUTH)) {
- return $this->getUrl('sales/guest/reorder', ['order_id' => $order->getId()]);
- }
- return $this->getUrl('sales/order/reorder', ['order_id' => $order->getId()]);
- }
- }
|