After misunderstanding how the config array works, I decided to extend and modify the AleFactory class to be more flexible. The part I changed is the foreach loop on lines 103-128 in the factory.php file. I replaced it with the following:
foreach($config as $key => $value) {
// parse the dot notation
$split = explode('.', $key, 2);
// if dot notation was used
if (count($split) == 2) {
// check for a class name
if ($split[0] == 'main' || $split[0] == 'cache' || $split[0] == 'request') {
// set key to class name
$key = $split[0];
} else {
// default to main
$key = 'main';
}
// assign the single value to an array
$value = array($split[1] => $value);
}
// populate config arrays with data
if ($key == 'main' && is_array($value)) {
foreach ($value as $k => $v) {
$mainConfig[$k] = $v;
}
} elseif ($key == 'cache' && is_array($value)) {
foreach ($value as $k => $v) {
$cacheConfig[$k] = $v;
}
} elseif ($key == 'request' && is_array($value)) {
foreach ($value as $k => $v) {
$requestConfig[$k] = $v;
}
} else {
// no class name means main config value
$mainConfig[$key] = $value;
}
}
This should work with all of the documented config options, and also allows the following sort of $config array:
$config = array(
'config' => false,
'main' => array(
'class' => 'EVEOnline',
'host' => 'http://api.eve-online.com/',
'suffix' => '.xml.aspx',
'parserClass' => 'SimpleXMLElement',
'requestError' => 'throwException',
'serverError' => 'throwException',
'cacheUpdateError' => array(103, 115, 116, 117, 119)
),
'request' => array(
'class' => 'curl',
'flattenParams' => false,
'timeout' => 10
),
'cache' => array(
'class' => 'file',
'rootdir' => 'cache/ale/eveonline'
)
);
I haven't thoroughly tested it to be sure it's backward-compatible with the other config modes, but I think it is. It's not an urgent addition or anything, but I thought I'd toss it out there. :-)
I'll have a look at it