|
@@ -68,12 +68,22 @@ class Router implements RouterInterface
|
|
'resource_type' => null,
|
|
'resource_type' => null,
|
|
);
|
|
);
|
|
|
|
|
|
- // check option names
|
|
|
|
- if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
|
|
|
|
- throw new \InvalidArgumentException(sprintf('The Router does not support the following options: \'%s\'.', implode('\', \'', $diff)));
|
|
|
|
|
|
+ // check option names and live merge, if errors are encountered Exception will be thrown
|
|
|
|
+ $invalid = array();
|
|
|
|
+ $isInvalid = false;
|
|
|
|
+ // This allows to avoid innefficients array_diff, array_keys, and so on, we only walks one the overriden options
|
|
|
|
+ // With array_keys, array_diff and array_merge there is 3 full walk of the $this->options array and 2 of $options.
|
|
|
|
+ foreach ($options as $key => $value) {
|
|
|
|
+ if (array_key_exists($key, $this->options)) {
|
|
|
|
+ $this->options[$key] = $value;
|
|
|
|
+ } else {
|
|
|
|
+ $isInvalid = true;
|
|
|
|
+ $invalid[] = $key;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ($isInvalid) {
|
|
|
|
+ throw new \InvalidArgumentException(sprintf('The Router does not support the following options: \'%s\'.', implode('\', \'', $invalid)));
|
|
}
|
|
}
|
|
-
|
|
|
|
- $this->options = array_merge($this->options, $options);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|