Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <tab id="testtab">
- <label>Test settings</label>
- </tab>
- <section id="testsection" type="text" showInDefault="1">
- <label>Test Configuration</label>
- <tab>testtab</tab>
- <resource>Namespace_Modulename::system_config</resource>
- <group id="settings" type="text" sortOrder="10" showInDefault="1">
- <label>Credentials</label>
- <field id="key" translate="label" type="text" sortOrder="30" showInDefault="1">
- <label>Key</label>
- </field>
- </group>
- </section>
- public function configDirective($construction)
- {
- $configValue = '';
- $params = $this->getParameters($construction[2]);
- $storeId = $this->getStoreId();
- if (isset($params['path']) && $this->isAvailableConfigVariable($params['path'])) {
- $configValue = $this->_scopeConfig->getValue(
- $params['path'],
- MagentoStoreModelScopeInterface::SCOPE_STORE,
- $storeId
- );
- }
- return $configValue;
- }
- private function isAvailableConfigVariable($variable)
- {
- return in_array(
- $variable,
- array_column($this->configVariables->getData(), 'value')
- );
- }
- <type name="MagentoEmailModelSourceVariables">
- <plugin name="add-test-credentials" type="[Vendor][Module]PluginModelSourceVariablePlugin" />
- </type>
- <?php
- namespace [Vendor][Module]PluginModelSource;
- use MagentoEmailModelSourceVariables;
- class VariablePlugin
- {
- /**
- * @param Variables $subject
- * @param $data
- * @return array
- */
- public function afterGetData(Variables $subject, $data)
- {
- $data[] = [
- 'value' => 'testsection/settings/key',
- 'label' => __('Credentials for test settings') //give it a label that suits you best. This will be listed in the insert custom var popup in the cms pages and blocks (see image below)
- ];
- return $data;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement