Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Tokens.php
Go to the documentation of this file.
1 <?php
7 
9 
17 class Tokens extends \Magento\Backend\Block\Widget\Form\Generic
18 {
22  const DATA_TOKEN = 'token';
23  const DATA_TOKEN_SECRET = 'token_secret';
24  const DATA_CONSUMER_KEY = 'consumer_key';
25  const DATA_CONSUMER_SECRET = 'consumer_secret';
33  protected function _prepareForm()
34  {
36  $form = $this->_formFactory->create();
37  $htmlIdPrefix = 'integration_token_';
38  $form->setHtmlIdPrefix($htmlIdPrefix);
39 
40  $fieldset = $form->addFieldset(
41  'base_fieldset',
42  ['legend' => __('Integration Tokens for Extensions'), 'class' => ' fieldset-wide']
43  );
44 
45  foreach ($this->getFormFields() as $field) {
46  $fieldset->addField($field['name'], $field['type'], $field['metadata']);
47  }
48 
49  $integrationData = $this->_coreRegistry->registry(IntegrationController::REGISTRY_KEY_CURRENT_INTEGRATION);
50  if ($integrationData) {
51  $form->setValues($integrationData);
52  }
53  $this->setForm($form);
54  return parent::_prepareForm();
55  }
56 
62  public function getFormFields()
63  {
64  return [
65  [
66  'name' => self::DATA_CONSUMER_KEY,
67  'type' => 'text',
68  'metadata' => [
69  'label' => __('Consumer Key'),
70  'name' => self::DATA_CONSUMER_KEY,
71  'readonly' => true,
72  ],
73  ],
74  [
76  'type' => 'text',
77  'metadata' => [
78  'label' => __('Consumer Secret'),
80  'readonly' => true,
81  ]
82  ],
83  [
84  'name' => self::DATA_TOKEN,
85  'type' => 'text',
86  'metadata' => ['label' => __('Access Token'), 'name' => self::DATA_TOKEN, 'readonly' => true]
87  ],
88  [
89  'name' => self::DATA_TOKEN_SECRET,
90  'type' => 'text',
91  'metadata' => [
92  'label' => __('Access Token Secret'),
93  'name' => self::DATA_TOKEN_SECRET,
94  'readonly' => true,
95  ]
96  ]
97  ];
98  }
99 }
setForm(\Magento\Framework\Data\Form $form)
Definition: Form.php:112
__()
Definition: __.php:13