Skip to content

Commit 182b661

Browse files
committed
Merge remote-tracking branch 'upstream/master' into show-path-optional
2 parents 8ad8668 + 72a402a commit 182b661

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

Plugin/ConfigFieldPlugin.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,18 @@ public function afterGetTooltip(Subject $subject, $result)
8787

8888
/**
8989
* @param Subject $subject
90-
* @param string $result
91-
* @return string
90+
* @param array $result
91+
* @return array
9292
*/
93-
public function afterGetComment(Subject $subject, $result)
94-
{
93+
public function afterGetData(
94+
Subject $subject,
95+
array $result
96+
) {
9597
if (!$this->scopeConfig->isSetFlag(self::CONFIG_SHOW_PATH)) {
9698
return $result;
9799
}
98100

99-
if ($result instanceof Phrase) {
100-
$result = (string) $result;
101-
}
102-
103-
if (strlen(trim($result))) {
104-
$result .= '<br />';
105-
}
106-
107-
$result .= __('Path: <code>%1</code>', $this->getPath($subject));
101+
$result['path_hint'] = '<small>' . __('Path: <code>%1</code>', $this->getPath($subject) . '</small>');
108102

109103
return $result;
110104
}

Plugin/ConfigFormFieldPlugin.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AvS\ScopeHint\Plugin;
6+
7+
use Magento\Config\Block\System\Config\Form\Field;
8+
use Magento\Framework\Data\Form\Element\AbstractElement;
9+
10+
class ConfigFormFieldPlugin
11+
{
12+
/**
13+
* @param Field $subject
14+
* @param AbstractElement $element
15+
*
16+
* @return array
17+
*/
18+
public function beforeRender(
19+
Field $subject,
20+
AbstractElement $element
21+
): array {
22+
$element->setData(
23+
'after_element_html',
24+
$element->getData('after_element_html') . $element->getData('field_config')['path_hint']
25+
);
26+
27+
return [$element];
28+
}
29+
}

etc/adminhtml/di.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@
77
<type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav">
88
<plugin name="avs_scopehint_plugin_field" type="AvS\ScopeHint\Plugin\ProductEavDataProviderPlugin" sortOrder="1" disabled="false" />
99
</type>
10-
</config>
10+
11+
<type name="Magento\Config\Block\System\Config\Form\Field">
12+
<plugin name="avs_scopehint_plugin_add_config_path"
13+
type="AvS\ScopeHint\Plugin\ConfigFormFieldPlugin"
14+
sortOrder="1"
15+
disabled="false"/>
16+
</type>
17+
</config>

0 commit comments

Comments
 (0)