Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrderButton.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
18  protected $authorization;
19 
26  public function __construct(
27  \Magento\Backend\Block\Widget\Context $context,
28  \Magento\Framework\Registry $registry
29  ) {
30  $this->authorization = $context->getAuthorization();
31  parent::__construct($context, $registry);
32  }
33 
37  public function getButtonData()
38  {
39  $customerId = $this->getCustomerId();
40  $data = [];
41  if ($customerId && $this->authorization->isAllowed('Magento_Sales::create')) {
42  $data = [
43  'label' => __('Create Order'),
44  'on_click' => sprintf("location.href = '%s';", $this->getCreateOrderUrl()),
45  'class' => 'add',
46  'sort_order' => 40,
47  ];
48  }
49  return $data;
50  }
51 
57  public function getCreateOrderUrl()
58  {
59  return $this->getUrl('sales/order_create/start', ['customer_id' => $this->getCustomerId()]);
60  }
61 }
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry)
Definition: OrderButton.php:26