Skip to content

Commit

Permalink
PresenterFactoryCallback: throws error "Refresh browser" when DI is u…
Browse files Browse the repository at this point in the history
…nable to create presenter instance

It may be caused by 'di > export > types' setting.
  • Loading branch information
dg committed Apr 3, 2019
1 parent e0b2675 commit 4f3b250
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Bridges/ApplicationDI/PresenterFactoryCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ public function __invoke(string $class): Nette\Application\IPresenter
touch($this->touchToRefresh);
}

$presenter = $this->container->createInstance($class);
$this->container->callInjects($presenter);
try {
$presenter = $this->container->createInstance($class);
$this->container->callInjects($presenter);
} catch (Nette\DI\MissingServiceException | Nette\DI\ServiceCreationException $e) {
if ($this->touchToRefresh && class_exists($class)) {
throw new \Exception("Refresh your browser. New presenter $class was found.", 0, $e);
}
throw $e;
}

if ($presenter instanceof Nette\Application\UI\Presenter && $presenter->invalidLinkMode === null) {
$presenter->invalidLinkMode = $this->invalidLinkMode;
}
Expand Down

0 comments on commit 4f3b250

Please sign in to comment.