public function addConfigDir($config_dir, $key = null)
{
// make sure we're dealing with an array
$this->config_dir = (array) $this->config_dir;
if (is_array($config_dir)) {
foreach ($config_dir as $k => $v) {
$v = str_replace(array('//', '\\\\'), DS, rtrim($v, '/\\')) . DS;
if (is_int($k)) {
// indexes are not merged but appended
$this->config_dir[] = $v;
} else {
// string indexes are overridden
$this->config_dir[$k] = $v;
}
}
} else {
$v = str_replace(array('//', '\\\\'), DS, rtrim($config_dir, '/\\')) . DS;
if ($key !== null) {
// override directory at specified index
$this->config_dir[$key] = rtrim($v, '/\\') . DS;
} else {
// append new directory
$this->config_dir[] = rtrim($v, '/\\') . DS;
}
}
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
return $this;
}