Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Java properties configuration file reader (separator) / Writer #44

Closed
nuxwin opened this issue Apr 19, 2018 · 2 comments
Closed

Java properties configuration file reader (separator) / Writer #44

nuxwin opened this issue Apr 19, 2018 · 2 comments

Comments

@nuxwin
Copy link

nuxwin commented Apr 19, 2018

@weierophinney

Good morning,

Could it be possible to make us able to setup the separator to use for the Java propertie configuration file reader? Right now, the colon sign is hardcoded, making us unable to change it by equal sign which should be also supported. You should also maybe considere a new option allowing to remove leading and trailing whitespaces from resulting key/value pairs.

For now, we have not other choice than doing i-MSCP/imscp@69df562
and then:

namespace iMSCP;

use iMSCP\Config\Reader\JavaProperties;
use iMSCP\Config\StandaloneReaderPluginManager;
use Zend\Config\Config;
use Zend\Config\Factory;

// Load default settings, that is, those that are overridable by administrator through GUI
$config = new Config(include_once 'default_settings.php', true);

// Load and merge settings from master i-MSCP configuration file.
// We need set our own JavaProperties configuration file reader as
// the one provided by ZF doesn't handle equal sign as separator
Factory::setReaderPluginManager(new StandaloneReaderPluginManager());
Factory::registerReader('conf', JavaProperties::class);
$config->merge(new Config(Factory::fromFile(CONFIG_FILE_PATH)));

Regarding the above code, maybe that the standalone reader plugin manager should also accept custom definitions because right now, we need provide our own.

Finally, could you provide a writer implementation for that configuration file type?

Thank you.

weierophinney added a commit to weierophinney/zend-config that referenced this issue Apr 24, 2018
Per zendframework#44, this patch adds the ability to specify via the constructor the
key/value pair delimiter to use when parsing a JavaProperties file. By
default, this will be `:`, but it can be any non-empty string.
weierophinney added a commit that referenced this issue Apr 24, 2018
weierophinney added a commit to weierophinney/zend-config that referenced this issue Apr 24, 2018
…lues

Per zendframework#44, this patch adds a constructor option allowing users to require
that keys and values are trimmed during parsing. This allows the
delimiter to be surrounded by whitespace, and also allows for
indentation:

```php
$reader = new JavaProperties(
    JavaProperties::DELIMITER_DEFAULT, // or ':'
    JavaProperties::WHITESPACE_TRIM    // or true
);
```
weierophinney added a commit to weierophinney/zend-config that referenced this issue Apr 24, 2018
Per zendframework#44, this patch provides a simple JavaProperties writer that uses
the configured delimiter in order to create key{delim}value lines
representing the configuration provided.
@weierophinney
Copy link
Member

Accomplished in:

These will release with 3.2.0 shortly.

@nuxwin
Copy link
Author

nuxwin commented Apr 24, 2018

@weierophinney

Thank you so much for your fast reaction here, and for the time you've spent on that issue. That is much appreciated.

Greetings from France.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants