public function initialize(array $config = array(), $reset = TRUE)
{
$reflection = new ReflectionClass($this);
if ($reset === TRUE) {
$defaults = $reflection->getDefaultProperties();
foreach (array_keys($defaults) as $key) {
if ($key[0] === '_') {
continue;
}
if (isset($config[$key])) {
if ($reflection->hasMethod('set_' . $key)) {
$this->{'set_' . $key}($config[$key]);
} else {
$this->{$key} = $config[$key];
}
} else {
$this->{$key} = $defaults[$key];
}
}
} else {
foreach ($config as $key => &$value) {
if ($key[0] !== '_' && $reflection->hasProperty($key)) {
if ($reflection->hasMethod('set_' . $key)) {
$this->{'set_' . $key}($value);
} else {
$this->{$key} = $value;
}
}
}
}
// if a file_name was provided in the config, use it instead of the user input
// supplied file name for all uploads until initialized again
$this->_file_name_override = $this->file_name;
return $this;
}