File tree Expand file tree Collapse file tree 2 files changed +6
-19
lines changed
src/Bridges/ApplicationDI Expand file tree Collapse file tree 2 files changed +6
-19
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ public function loadConfiguration(): void
9696 ->setType (Nette \Application \IPresenterFactory::class)
9797 ->setFactory (Nette \Application \PresenterFactory::class, [new Definitions \Statement (
9898 Nette \Bridges \ApplicationDI \PresenterFactoryCallback::class,
99- [1 => $ this -> invalidLinkMode , $ touch ?? null ],
99+ [1 => $ touch ?? null ],
100100 )]);
101101
102102 if ($ config ->mapping ) {
Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ final class PresenterFactoryCallback
2020{
2121 public function __construct (
2222 private readonly Nette \DI \Container $ container ,
23- private readonly int $ invalidLinkMode ,
2423 private readonly ?string $ touchToRefresh ,
2524 ) {
2625 }
@@ -40,25 +39,13 @@ public function __invoke(string $class): Nette\Application\IPresenter
4039 return $ this ->container ->createService ($ services [0 ]);
4140 }
4241
43- if ($ this ->touchToRefresh ) {
42+ if ($ this ->touchToRefresh && class_exists ( $ class ) ) {
4443 touch ($ this ->touchToRefresh );
44+ header ('Refresh: 3 ' );
45+ echo "The DI container does not know the $ class. I will refresh it in 3 seconds. " ;
46+ exit ;
4547 }
4648
47- try {
48- $ presenter = $ this ->container ->createInstance ($ class );
49- $ this ->container ->callInjects ($ presenter );
50- } catch (Nette \DI \MissingServiceException | Nette \DI \ServiceCreationException $ e ) {
51- if ($ this ->touchToRefresh && class_exists ($ class )) {
52- throw new \Exception ("Refresh your browser. New presenter $ class was found. " , 0 , $ e );
53- }
54-
55- throw $ e ;
56- }
57-
58- if ($ presenter instanceof Nette \Application \UI \Presenter && !isset ($ presenter ->invalidLinkMode )) {
59- $ presenter ->invalidLinkMode = $ this ->invalidLinkMode ;
60- }
61-
62- return $ presenter ;
49+ throw new Nette \Application \InvalidPresenterException ("No services of type $ class found. " );
6350 }
6451}
You can’t perform that action at this time.
0 commit comments