Skip to content

Instantly share code, notes, and snippets.

@magevision
Created October 29, 2017 13:55
Show Gist options
  • Save magevision/7b8980e6b637c6f02a272e84771a48d3 to your computer and use it in GitHub Desktop.
Save magevision/7b8980e6b637c6f02a272e84771a48d3 to your computer and use it in GitHub Desktop.
Blog Post 23
<?php
namespace MageVision\Blog23\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\Encryption\EncryptorInterface;
class Data extends AbstractHelper
{
const XML_PATH_PASSWORD = 'blog/post23/password';
/**
* @var EncryptorInterface
*/
protected $encryptor;
/**
* @param EncryptorInterface $encryptor
*/
public function __construct(
EncryptorInterface $encryptor
) {
$this->encryptor = $encryptor;
}
/**
* Get Password from config
*
* @return string
*/
public function getPassword()
{
$password = $this->scopeConfig->getValue(self::XML_PATH_PASSWORD, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
return $this->encryptor->decrypt($password);
}
}
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="magevision" translate="label" sortOrder="1000">
<label>MageVision Blog Posts</label>
</tab>
<section id="blog" translate="label" type="text" sortOrder="1009" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Blog Post 23</label>
<tab>magevision</tab>
<resource>MageVision_Blog23::blog23_configuration</resource>
<group id="post23" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General</label>
<field id="password" translate="label" sortOrder="10" type="obscure" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Password</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>
</group>
</section>
</system>
</config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment