Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
View.php
Go to the documentation of this file.
1 <?php
7 
14 class View extends \Magento\Backend\Block\Widget\Form\Container
15 {
21  protected $_coreRegistry = null;
22 
28  public function __construct(
29  \Magento\Backend\Block\Widget\Context $context,
30  \Magento\Framework\Registry $registry,
31  array $data = []
32  ) {
33  $this->_coreRegistry = $registry;
34  parent::__construct($context, $data);
35  }
36 
42  protected function _construct()
43  {
44  $this->_objectId = 'agreement';
45  $this->_controller = 'adminhtml_billing_agreement';
46  $this->_mode = 'view';
47  $this->_blockGroup = 'Magento_Paypal';
48 
49  parent::_construct();
50 
51  if (!$this->_isAllowed('Magento_Paypal::actions_manage')) {
52  $this->buttonList->remove('delete');
53  }
54  $this->buttonList->remove('reset');
55  $this->buttonList->remove('save');
56  $this->setId('billing_agreement_view');
57 
58  $this->buttonList->add(
59  'back',
60  [
61  'label' => __('Back'),
62  'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
63  'class' => 'back'
64  ],
65  -1
66  );
67 
68  $agreement = $this->_getBillingAgreement();
69  if ($agreement && $agreement->canCancel() && $this->_isAllowed('Magento_Paypal::actions_manage')) {
70  $confirmText = __('Are you sure you want to do this?');
71  $this->buttonList->add(
72  'cancel',
73  [
74  'label' => __('Cancel'),
75  'onclick' => "confirmSetLocation(" . "'{$confirmText}', '{$this->_getCancelUrl()}'" . ")",
76  'class' => 'cancel'
77  ],
78  -1
79  );
80  }
81  }
82 
88  public function getHeaderText()
89  {
90  return __('Billing Agreement #%1', $this->_getBillingAgreement()->getReferenceId());
91  }
92 
98  protected function _getCancelUrl()
99  {
100  return $this->getUrl('*/*/cancel', ['agreement' => $this->_getBillingAgreement()->getAgreementId()]);
101  }
102 
108  protected function _getBillingAgreement()
109  {
110  return $this->_coreRegistry->registry('current_billing_agreement');
111  }
112 
119  protected function _isAllowed($resourceId)
120  {
121  return $this->_authorization->isAllowed($resourceId);
122  }
123 }
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, array $data=[])
Definition: View.php:28