Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UnlockButton.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  protected $customerRegistry;
20 
28  public function __construct(
29  \Magento\Backend\Block\Widget\Context $context,
30  \Magento\Framework\Registry $registry,
32  ) {
33  parent::__construct($context, $registry);
34  $this->customerRegistry = $customerRegistry;
35  }
36 
42  public function getButtonData()
43  {
44  $customerId = $this->getCustomerId();
45  $data = [];
46  if ($customerId) {
47  $customer = $this->customerRegistry->retrieve($customerId);
48  if ($customer->isCustomerLocked()) {
49  $data = [
50  'label' => __('Unlock'),
51  'class' => 'unlock unlock-customer',
52  'on_click' => sprintf("location.href = '%s';", $this->getUnlockUrl()),
53  'sort_order' => 50,
54  ];
55  }
56  }
57  return $data;
58  }
59 
65  protected function getUnlockUrl()
66  {
67  return $this->getUrl('customer/locks/unlock', ['customer_id' => $this->getCustomerId()]);
68  }
69 }
$customer
Definition: customers.php:11
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, CustomerRegistry $customerRegistry)