mirror of
https://github.com/friendica/friendica
synced 2025-04-26 01:10:15 +00:00
Make InstanceManager strategy naming convention case insensitive.
This commit is contained in:
parent
06df62a2b5
commit
6bcf5cb823
2 changed files with 23 additions and 4 deletions
|
@ -49,11 +49,11 @@ class DiceInstanceManager implements ICanCreateInstances, ICanRegisterStrategies
|
|||
/** {@inheritDoc} */
|
||||
public function registerStrategy(string $interface, string $class, ?string $name = null): ICanRegisterStrategies
|
||||
{
|
||||
if (!empty($this->instance[$interface][$name])) {
|
||||
if (!empty($this->instance[$interface][strtolower($name)])) {
|
||||
throw new HookRegisterArgumentException(sprintf('A class with the name %s is already set for the interface %s', $name, $interface));
|
||||
}
|
||||
|
||||
$this->instance[$interface][$name] = $class;
|
||||
$this->instance[$interface][strtolower($name)] = $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ class DiceInstanceManager implements ICanCreateInstances, ICanRegisterStrategies
|
|||
/** {@inheritDoc} */
|
||||
public function create(string $class, string $strategy, array $arguments = []): object
|
||||
{
|
||||
if (empty($this->instance[$class][$strategy])) {
|
||||
if (empty($this->instance[$class][strtolower($strategy)])) {
|
||||
throw new HookInstanceException(sprintf('The class with the name %s isn\'t registered for the class or interface %s', $strategy, $class));
|
||||
}
|
||||
|
||||
return $this->dice->create($this->instance[$class][$strategy], $arguments);
|
||||
return $this->dice->create($this->instance[$class][strtolower($strategy)], $arguments);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue