Skip to content

Commit

Permalink
PresenterFactoryCallback: fixed multiple services of type found [Closes
Browse files Browse the repository at this point in the history
#258]

fixes cb35435
  • Loading branch information
dg committed Apr 2, 2020
1 parent 7bf38fb commit 5c66e7d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Bridges/ApplicationDI/PresenterFactoryCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public function __invoke(string $class): Nette\Application\IPresenter
{
$services = $this->container->findByType($class);
if (count($services) > 1) {
foreach ($services as $service) {
if ($this->container->getServiceType($service) === $class) {
return $this->container->createService($service);
}
}
throw new Nette\Application\InvalidPresenterException("Multiple services of type $class found: " . implode(', ', $services) . '.');

} elseif (!$services) {
Expand Down

0 comments on commit 5c66e7d

Please sign in to comment.