Task: #53687 Support instance-specific cfg write targets and add coverage

This commit is contained in:
Alejandro Sosa 2026-03-25 16:39:28 +01:00
commit 2737ec1d65
4 changed files with 484 additions and 15 deletions

View file

@ -22,6 +22,8 @@
declare(strict_types=1);
namespace rabe\Util;
use ErrorException;
/**
* Write Settings into a File
* @author Norbert.e.Wagner dev@norb.me
@ -45,13 +47,16 @@ class SettingsWriter
*
* @param Settings $settings an object of type settings
* @param String $name The name midfix for the settings File
*/
public function __construct( Settings $settings, $name='' )
* @param String|int|null $type Optional type for Settings::buildFileName(), e.g. site flag
*/
public function __construct( Settings $settings, $name='', $type=null )
{
$this->settings = $settings;
$file = $settings->buildFileName( $name );
$file = ( $type === null )
? $settings->buildFileName( $name )
: $settings->buildFileName( $type );
if ( ! $this->handle = fopen( $file, 'w' ) )
{
throw new ErrorException( "Can not open File: $file" );