2323use Gt \Http \Stream ;
2424use GT \Input \Input ;
2525use GT \Input \InputData \InputData ;
26+ use Gt \Json \Schema \JsonDocument ;
2627use GT \Routing \Assembly ;
2728use Gt \Routing \BaseRouter ;
2829use GT \Routing \Path \DynamicPath ;
@@ -58,8 +59,8 @@ class Dispatcher {
5859
5960 private Injector $ injector ;
6061 private NullView |JSONView |HTMLView $ view ;
61- private HTMLDocument /*|NullViewModel*/ $ viewModel ;
62- private ViewModelProcessor $ viewModelProcessor ;
62+ private HTMLDocument | JsonDocument $ viewModel ;
63+ private ? ViewModelProcessor $ viewModelProcessor ;
6364 private BaseRouter $ router ;
6465 private ?SessionInit $ sessionInit = null ;
6566 private Assembly $ logicAssembly ;
@@ -186,7 +187,8 @@ public function __construct(
186187 $ this ->config ->getString ("view.partial_directory " ),
187188 );
188189 $ this ->viewModelProcessor = $ viewModelInit ->getViewModelProcessor ();
189- $ this ->viewModelInitCallback = fn () => $ viewModelInit ->initHTMLDocument (
190+ $ this ->viewModelInitCallback = $ this ->viewModel instanceof HTMLDocument
191+ ? fn () => $ viewModelInit ->initHTMLDocument (
190192 $ this ->serviceContainer ->get (Binder::class),
191193 $ this ->serviceContainer ->get (HTMLAttributeBinder::class),
192194 $ this ->serviceContainer ->get (ListBinder::class),
@@ -196,7 +198,8 @@ public function __construct(
196198 $ this ->serviceContainer ->get (HTMLAttributeCollection::class),
197199 $ this ->serviceContainer ->get (ListElementCollection::class),
198200 $ this ->serviceContainer ->get (BindableCache::class),
199- );
201+ )
202+ : fn () => null ;
200203
201204 $ this ->logicExecutor = $ logicExecutor ?? new LogicExecutor (
202205 $ appNamespace ,
@@ -369,12 +372,12 @@ public function processResponse(
369372 ):void {
370373 $ dynamicPath = $ this ->serviceContainer ->get (DynamicPath::class);
371374
372- $ this ->viewModelProcessor ->processDynamicPath (
375+ $ this ->viewModelProcessor ? ->processDynamicPath(
373376 $ this ->viewModel ,
374377 $ dynamicPath ,
375378 );
376379
377- $ logicAssemblyComponentList = $ this ->viewModelProcessor ->processPartialContent (
380+ $ logicAssemblyComponentList = $ this ->viewModelProcessor ? ->processPartialContent(
378381 $ this ->viewModel ,
379382 );
380383
@@ -384,7 +387,7 @@ public function processResponse(
384387 $ this ->bindErrorDetails ($ errorThrowable );
385388 }
386389
387- foreach ($ logicAssemblyComponentList as $ logicAssemblyComponent ) {
390+ foreach ($ logicAssemblyComponentList ?? [] as $ logicAssemblyComponent ) {
388391 $ assembly = $ logicAssemblyComponent ->assembly ;
389392 $ componentElement = $ logicAssemblyComponent ->component ;
390393 $ this ->serviceContainer ->set ($ componentElement );
0 commit comments