Task: #53687 Support instance-specific cfg write targets and add coverage
This commit is contained in:
parent
65178d7ba2
commit
2737ec1d65
4 changed files with 484 additions and 15 deletions
|
|
@ -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" );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue