magento2-docker/app/code/IpSupply/SyncOrder/Config/Setter.php

36 lines
932 B
PHP
Executable File

<?php
namespace IpSupply\SyncOrder\Config;
use IpSupply\SyncOrder\Helper;
use Magento\Framework\App\Config\Storage\WriterInterface;
class Setter
{
protected $configWriter;
static function set($path, $value, $prefix = true)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$configSetter = $objectManager->create(self::class);
$path = $prefix
? Helper::PREFIX . '/' . $path
: $path;
$configSetter->setConfigValue($path, $value);
// Clean cache old
$cacheManager = $objectManager->get(\Magento\Framework\App\Cache\Manager::class);
$cacheManager->flush(['config']);
}
public function __construct(WriterInterface $configWriter)
{
$this->configWriter = $configWriter;
}
public function setConfigValue($fullPath, $value)
{
$this->configWriter->save($fullPath, $value);
}
}