From 7840859db8df64b81214fe37b78bf9dc975045e9 Mon Sep 17 00:00:00 2001 From: Simon Sprankel Date: Thu, 13 Jan 2022 17:36:56 +0100 Subject: [PATCH] Respect comment type, fixes #20 --- Plugin/ConfigFieldPlugin.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugin/ConfigFieldPlugin.php b/Plugin/ConfigFieldPlugin.php index a0ee3ca..697b8b3 100644 --- a/Plugin/ConfigFieldPlugin.php +++ b/Plugin/ConfigFieldPlugin.php @@ -4,6 +4,7 @@ use Magento\Config\Model\Config\Structure\Element\Field as Subject; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\RequestInterface; +use Magento\Framework\Phrase; use Magento\Store\Api\WebsiteRepositoryInterface; use Magento\Store\Api\StoreRepositoryInterface; use Magento\Store\Api\Data\WebsiteInterface; @@ -75,10 +76,22 @@ public function afterGetTooltip(Subject $subject, $result) */ public function afterGetComment(Subject $subject, $result) { + $resultIsPhrase = $result instanceof Phrase; + if ($resultIsPhrase) { + $phrase = $result; + $result = $phrase->getText(); + $arguments = $phrase->getArguments(); + } + if (strlen(trim($result))) { $result .= '
'; } $result .= __('Path: %1', $this->getPath($subject)); + + if ($resultIsPhrase) { + $result = new Phrase($result, $arguments); + } + return $result; } @@ -130,4 +143,4 @@ private function getScopeHint($path, $scopeType, $scope) } return $scopeLine; } -} \ No newline at end of file +}