Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ApiWizard.php
Go to the documentation of this file.
1 <?php
7 
11 class ApiWizard extends \Magento\Config\Block\System\Config\Form\Field
12 {
16  const WIZARD_TEMPLATE = 'Magento_Paypal::system/config/api_wizard.phtml';
17 
23  protected function _prepareLayout()
24  {
25  parent::_prepareLayout();
26  if (!$this->getTemplate()) {
27  $this->setTemplate(static::WIZARD_TEMPLATE);
28  }
29  return $this;
30  }
31 
38  public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
39  {
40  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
41  return parent::render($element);
42  }
43 
50  protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
51  {
52  $originalData = $element->getOriginalData();
53  $this->addData(
54  [
55  // Global
56  'query' => $this->createQuery(
57  [
58  'partnerId' => $originalData['partner_id'],
59  'partnerLogoUrl' => $this->_assetRepo->getUrl($originalData['partner_logo_url']),
60  'receiveCredentials' => $originalData['receive_credentials'],
61  'showPermissions' => $originalData['show_permissions'],
62  'displayMode' => $originalData['display_mode'],
63  'productIntentID' => $originalData['product_intent_id'],
64  ]
65  ),
66  // Live
67  'button_label' => __($originalData['button_label']),
68  'button_url' => $originalData['button_url'],
69  'html_id' => $element->getHtmlId(),
70  // Sandbox
71  'sandbox_button_label' => __($originalData['sandbox_button_label']),
72  'sandbox_button_url' => $originalData['sandbox_button_url'],
73  'sandbox_html_id' => 'sandbox_' . $element->getHtmlId(),
74  ]
75  );
76  return $this->_toHtml();
77  }
78 
85  private function createQuery(array $requestData)
86  {
87  $query = [];
88 
89  foreach ($requestData as $name => $value) {
90  $query[] = sprintf('%s=%s', $name, $value);
91  }
92 
93  return implode('&', $query);
94  }
95 }
render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
Definition: ApiWizard.php:38
__()
Definition: __.php:13
$value
Definition: gender.phtml:16
_getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
Definition: ApiWizard.php:50
if(!isset($_GET['name'])) $name
Definition: log.php:14
$element
Definition: element.phtml:12