Skip to content

Commit dfdace2

Browse files
authored
Merge pull request #24 from fredden/show-path-optional
Optionally show path for configuration options
2 parents d736774 + 182b661 commit dfdace2

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

Plugin/ConfigFieldPlugin.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class ConfigFieldPlugin
1717
const SCOPE_TYPE_WEBSITES = 'websites';
1818
const SCOPE_TYPE_STORES = 'stores';
1919

20+
private const CONFIG_SHOW_PATH = 'dev/debug/show_path_in_adminhtml';
21+
2022
/** @var Escaper */
2123
private $escaper;
2224

@@ -92,6 +94,10 @@ public function afterGetData(
9294
Subject $subject,
9395
array $result
9496
) {
97+
if (!$this->scopeConfig->isSetFlag(self::CONFIG_SHOW_PATH)) {
98+
return $result;
99+
}
100+
95101
$result['path_hint'] = '<small>' . __('Path: <code>%1</code>', $this->getPath($subject) . '</small>');
96102

97103
return $result;

etc/adminhtml/system.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
4+
<system>
5+
<section id="dev">
6+
<group id="debug">
7+
<field id="show_path_in_adminhtml" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
8+
<label>Display path for each option in system configuration</label>
9+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
10+
</field>
11+
</group>
12+
</section>
13+
</system>
14+
</config>

etc/config.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
4+
<default>
5+
<dev>
6+
<debug>
7+
<show_path_in_adminhtml>1</show_path_in_adminhtml>
8+
</debug>
9+
</dev>
10+
</default>
11+
</config>

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ See the screenshot to get an impression of what the module does:
1717

1818
![Screenshot](scopehint2-screenshot.png?raw=true "ScopeHint for Magento 2")
1919

20-
The module also displays the configuration code (which is used for `ScopeConfigInterface::getValue()`) with the configuration fields.
20+
The module also optionally displays the configuration code (which is used for `ScopeConfigInterface::getValue()`) with the configuration fields.
21+
This is on by default, and can be enabled/disabled in
22+
Stores -> Settings -> Configuration -> Advanced -> Developer -> Debug -> `Display path for each option in system configuration`
2123

2224
Requirements
2325
------------

0 commit comments

Comments
 (0)