Skip to content

Commit

Permalink
Avoid calling getContext() on presenters not supporting this getter
Browse files Browse the repository at this point in the history
  • Loading branch information
xificurk committed Oct 28, 2024
1 parent 2ea8630 commit 5df0639
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Kdyby/Autowired/AutowireComponentFactories.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ trait AutowireComponentFactories
protected function getComponentFactoriesLocator(): Nette\DI\Container
{
if (! isset($this->autowireComponentFactoriesLocator)) {
$this->injectComponentFactories($this->getPresenter()->getContext());
$presenter = $this->getPresenter();
if (! method_exists($presenter, 'getContext')) {
throw new InvalidStateException('Cannot get DI Container service - are inject methods allowed?');
}
$this->injectComponentFactories($presenter->getContext());
}

return $this->autowireComponentFactoriesLocator;
Expand Down

0 comments on commit 5df0639

Please sign in to comment.