From ca939f3c3e3e1e3a9c216b110389f53e6fd2aa2c Mon Sep 17 00:00:00 2001 From: Andre Santiago Date: Wed, 11 May 2022 13:48:06 -0400 Subject: [PATCH] Adding field in Admin Configuration to allow developer to see the current IP --- .../System/Config/Form/Field/DeveloperIps.php | 69 +++++++++++++++++++ etc/adminhtml/system.xml | 4 ++ .../system/config/developer_ips.phtml | 6 ++ 3 files changed, 79 insertions(+) create mode 100644 Block/Adminhtml/System/Config/Form/Field/DeveloperIps.php create mode 100644 view/adminhtml/system/config/developer_ips.phtml diff --git a/Block/Adminhtml/System/Config/Form/Field/DeveloperIps.php b/Block/Adminhtml/System/Config/Form/Field/DeveloperIps.php new file mode 100644 index 0000000..e8fa854 --- /dev/null +++ b/Block/Adminhtml/System/Config/Form/Field/DeveloperIps.php @@ -0,0 +1,69 @@ +_remoteAddress = $remoteAddress; + } + + /** + * Remove scope label + * + * @param AbstractElement $element + * @return string + */ + public function render(AbstractElement $element) + { + $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); + return parent::render($element); + } + + /** + * Return element html + * + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) + { + return $this->_toHtml(); + } + + /** + * return String IP address + */ + public function getIpAddress() + { + return $this->_remoteAddress->getRemoteAddress(); + } +} + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index c3981e8..51840b5 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -61,6 +61,10 @@ 1 + + + Flancer32\Csp\Block\Adminhtml\System\Config\Form\Field\DeveloperIps + 1 diff --git a/view/adminhtml/system/config/developer_ips.phtml b/view/adminhtml/system/config/developer_ips.phtml new file mode 100644 index 0000000..94bea8a --- /dev/null +++ b/view/adminhtml/system/config/developer_ips.phtml @@ -0,0 +1,6 @@ + +
getIpAddress(); ?>