![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/colissimo/module-shipping/Block/Adminhtml/System/Config/ |
<?php /** * Colissimo Shipping Module * * @author Magentix * @copyright Copyright © 2018 Magentix. All rights reserved. * @license https://www.magentix.fr/en/licence.html Magentix Software Licence * @link https://colissimo.magentix.fr/ */ namespace Colissimo\Shipping\Block\Adminhtml\System\Config; use Colissimo\Shipping\Helper\Data as ShippingHelper; use Magento\Backend\Block\Template\Context; use Magento\Config\Block\System\Config\Form\Field; use Magento\Backend\Block\Widget\Button; use Magento\Framework\Data\Form\Element\AbstractElement; /** * Class Test */ class Test extends Field { /** * @var ShippingHelper $shippingHelper */ protected $shippingHelper; /** * @param Context $context * @param ShippingHelper $shippingHelper * @param array $data */ public function __construct( Context $context, ShippingHelper $shippingHelper, array $data = [] ) { $this->shippingHelper = $shippingHelper; parent::__construct($context, $data); } /** * Retrieve element HTML markup * * @param AbstractElement $element * @return string * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @phpcs:disable */ protected function _getElementHtml(AbstractElement $element) { /** @var \Magento\Backend\Block\Widget\Button $buttonBlock */ $buttonBlock = $this->getForm()->getLayout()->createBlock(Button::class); $website = $buttonBlock->getRequest()->getParam('website'); $store = $buttonBlock->getRequest()->getParam('store'); $params = [ 'website' => $website, 'store' => $store ]; $data = [ 'label' => $this->getLabel(), 'onclick' => "setLocation('" . $this->getTestUrl($params) . "')", ]; $apiConfig = $this->shippingHelper->getApiConfig($store, $website); if (!$apiConfig['login'] || !$apiConfig['password']) { $data['disabled'] = true; } $html = $buttonBlock->setData($data)->toHtml(); return $html; } /** * Retrieve button label * * @return \Magento\Framework\Phrase */ private function getLabel() { return __('Test'); } /** * Retrieve Button URL * * @param array * @return string */ public function getTestUrl($params = []) { return $this->getUrl('colissimo_shipping/test', $params); } }