Skip to content

Commit

Permalink
nette/DI 3.0.2 compatiblity (#27)
Browse files Browse the repository at this point in the history
* nette/DI 3.0.2 compatiblity  

There is BC in this release
https://github.com/nette/di/releases/tag/v3.0.2

* Update src/Kdyby/Autowired/AutowireComponentFactories.php

Co-Authored-By: Jáchym Toušek <[email protected]>

* Minimal version of nette/di is 3.0.2

Co-authored-by: Jáchym Toušek <[email protected]>
  • Loading branch information
chapcz and enumag authored Feb 6, 2020
1 parent ee9c3a6 commit f82cde0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require": {
"php": "^7.1",
"nette/di": "^3.0",
"nette/di": "^3.0.2",
"nette/application": "^3.0",
"nette/reflection": "^2.4.2",
"tracy/tracy": "^2.6"
Expand Down
6 changes: 4 additions & 2 deletions src/Kdyby/Autowired/AutowireComponentFactories.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ private function findByTypeForFactory(string $type)
*/
protected function createComponent(string $name): ?IComponent
{
$sl = $this->getComponentFactoriesLocator();
$getter = function (string $type) {
return $this->getComponentFactoriesLocator()->getByType($type);
};

$ucName = ucfirst($name);
$method = 'createComponent' . $ucName;
Expand All @@ -131,7 +133,7 @@ protected function createComponent(string $name): ?IComponent
$args[] = $name;
}

$args = Nette\DI\Resolver::autowireArguments($methodReflection, $args, $sl);
$args = Nette\DI\Resolver::autowireArguments($methodReflection, $args, $getter);
$component = $this->{$method}(...$args);
if (!$component instanceof Nette\ComponentModel\IComponent && !isset($this->components[$name])) {
throw new Nette\UnexpectedValueException("Method $methodReflection did not return or create the desired component.");
Expand Down

0 comments on commit f82cde0

Please sign in to comment.