-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MeCapron/master
Handled custom configuration for logger
- Loading branch information
Showing
8 changed files
with
164 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Opengento\Logger\Block\Adminhtml\System\Config\Form\Field; | ||
|
||
class Type extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray | ||
{ | ||
|
||
/** | ||
* @var \Magento\Framework\Data\Form\Element\Factory | ||
*/ | ||
protected $_elementFactory; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Framework\Data\Form\Element\Factory $elementFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\Data\Form\Element\Factory $elementFactory, | ||
array $data = [] | ||
) { | ||
$this->_elementFactory = $elementFactory; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Initialise form fields | ||
* | ||
* @return void | ||
*/ | ||
protected function _construct() | ||
{ | ||
$this->addColumn('custom_logger_key', ['label' => __('Logger key')]); | ||
$this->addColumn('custom_logger_value', ['label' => __('Logger value')]); | ||
$this->_addAfter = false; | ||
$this->_addButtonLabel = __('Add'); | ||
parent::_construct(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Opengento\Logger\Config; | ||
|
||
use \Magento\Framework\App\Helper\AbstractHelper; | ||
|
||
/** | ||
* Class Config | ||
* @package Opengento\Logger\Config | ||
*/ | ||
class Config extends AbstractHelper | ||
{ | ||
/** Config keys */ | ||
const CONFIG_LOGGER_CUSTOM_CONFIGURATION = 'loggin/loggin/types_logger'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Opengento\Logger\Config; | ||
|
||
/** | ||
* Class CustomConfiguration | ||
*/ | ||
class CustomConfiguration | ||
{ | ||
/** | ||
* @var \Magento\Framework\App\Config\ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
|
||
/** | ||
* @var \Magento\Framework\Serialize\Serializer\Json | ||
*/ | ||
private $serializer; | ||
|
||
|
||
/** | ||
* CustomFields constructor. | ||
* @param \Magento\Framework\App\Helper\Context $context | ||
* @param \Magento\Framework\Serialize\Serializer\Json $serializer | ||
*/ | ||
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Serialize\Serializer\Json $serializer) | ||
{ | ||
$this->scopeConfig = $scopeConfig; | ||
$this->serializer = $serializer; | ||
} | ||
|
||
/** | ||
* @param $configPath | ||
* @param null $store | ||
* @return mixed | ||
*/ | ||
public function getConfigValue($configPath, $store = null){ | ||
return $this->scopeConfig->getValue( | ||
$configPath, | ||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE, | ||
$store | ||
); | ||
} | ||
|
||
/** | ||
* @param $configPath | ||
* @param null $store | ||
* @return array|bool|float|int|mixed|string|null | ||
*/ | ||
public function getUnserializedConfigValue($configPath, $store = null){ | ||
$value = $this->getConfigValue($configPath, $store); | ||
|
||
if(!$value) return false; | ||
|
||
return $this->serializer->unserialize($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"Enable ?", "Activé ?" | ||
"Gelf transport host", "Gelf transport host" | ||
"Gelf transport port", "Gelf transport port" | ||
"Custom configuration", "Configuration personnalisée" | ||
"Add key with custom value", "Ajoute une clé avec des valeurs personnalisées" | ||
"Logger key", "Logger key" | ||
"Logger value", "Logger value" |