| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/GXModules/Gambio/StyleEdit/Core/Helpers/ |
Upload File : |
<?php
/* --------------------------------------------------------------
DefaultOverwriteCreator.php 2019-10-15
Gambio GmbH
http://www.gambio.de
Copyright (c) 2019 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------*/
namespace Gambio\StyleEdit\Core\Helpers;
use FilesystemAdapter;
use Gambio\StyleEdit\Core\Json\InheritanceHandler;
use stdClass;
/**
* Class DefaultOverwriteCreator
*/
class DefaultOverwriteCreator
{
public const OVERWRITE_DIRECTORY_NAME = 'theme_extensions';
/**
* @var string
*/
protected $themeId;
/**
* @var FilesystemAdapter
*/
protected $themeFilesystem;
/**
* @var ConvertSettingsToDefaultValueThemeExtensions
*/
protected $converter;
/**
* DefaultOverwriteCreator constructor.
*
* @param string $themeId
* @param FilesystemAdapter $themeFilesystem
* @param ConvertSettingsToDefaultValueThemeExtensions $converter
*/
public function __construct(
string $themeId,
FilesystemAdapter $themeFilesystem,
ConvertSettingsToDefaultValueThemeExtensions $converter
) {
$this->themeId = $themeId;
$this->themeFilesystem = $themeFilesystem;
$this->converter = $converter;
}
public function store(): void
{
foreach ($this->converter->convert() as $id => $default) {
$overwritePath = $this->themeId . DIRECTORY_SEPARATOR . self::OVERWRITE_DIRECTORY_NAME
. DIRECTORY_SEPARATOR . $id . '.json';
$value = new stdClass;
$value->extension_type = InheritanceHandler::MERGE;
$value->default = $default;
if ($this->themeFilesystem->has($overwritePath) === false) {
$this->themeFilesystem->write($overwritePath, json_encode($value));
} else {
$this->themeFilesystem->delete($overwritePath);
$this->themeFilesystem->write($overwritePath, json_encode($value));
}
}
}
}