Skip to content

Commit 2024ff8

Browse files
committed
tweak: fix order of domtemplate initialisation
1 parent b3ccb7c commit 2024ff8

File tree

6 files changed

+15
-40
lines changed

6 files changed

+15
-40
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@
5252

5353
"autoload": {
5454
"psr-4": {
55-
"Gt\\WebEngine\\": "./src/"
55+
"GT\\WebEngine\\": "./src/"
5656
}
5757
},
5858
"autoload-dev": {
5959
"psr-4": {
60-
"Gt\\WebEngine\\Test\\": "./test/phpunit"
60+
"GT\\WebEngine\\Test\\": "./test/phpunit"
6161
}
6262
},
6363

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Dispatch/Dispatcher.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public function __construct(
171171
$this->viewModel,
172172
$this->config->getString("view.component_directory"),
173173
$this->config->getString("view.partial_directory"),
174+
);
175+
$this->viewModelProcessor = $viewModelInit->getViewModelProcessor();
176+
$this->viewREADYTHING = fn() => $viewModelInit->initHTMLDocument(
174177
$this->serviceContainer->get(DocumentBinder::class),
175178
$this->serviceContainer->get(HTMLAttributeBinder::class),
176179
$this->serviceContainer->get(ListBinder::class),
@@ -181,8 +184,6 @@ public function __construct(
181184
$this->serviceContainer->get(ListElementCollection::class),
182185
$this->serviceContainer->get(BindableCache::class),
183186
);
184-
$this->viewModelProcessor = $viewModelInit->getViewModelProcessor();
185-
$this->viewREADYTHING = $viewModelInit->init(...);
186187

187188
$this->logicExecutor = $logicExecutor ?? new LogicExecutor(
188189
$appNamespace,
@@ -197,7 +198,6 @@ public function generateResponse():Response {
197198
// function's responsibility is to execute the logic that builds the response.
198199
// Since this involves running user code that may throw errors, we execute each
199200
// step individually to ensure proper error handling throughout the process.
200-
$appNamespace = $this->config->getString("app.namespace");
201201
$dynamicPath = $this->serviceContainer->get(DynamicPath::class);
202202

203203
$this->viewModelProcessor->processDynamicPath(
@@ -209,6 +209,7 @@ public function generateResponse():Response {
209209
$this->viewModel,
210210
);
211211

212+
212213
// TODO: CSRF handling - needs to be done on any POST request.
213214
($this->viewREADYTHING)();
214215
foreach($logicAssemblyComponentList as $logicAssemblyComponent) {

src/Init/ViewModelInit.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,24 @@
1919

2020
class ViewModelInit {
2121
private ViewModelProcessor $viewModelProcessor;
22-
private Closure $initFunction;
2322

2423
public function __construct(
2524
HTMLDocument $model,
2625
string $componentDirectory,
2726
string $partialDirectory,
28-
DocumentBinder $binder,
29-
HTMLAttributeBinder $htmlAttributeBinder,
30-
ListBinder $listBinder,
31-
TableBinder $tableBinder,
32-
ElementBinder $elementBinder,
33-
PlaceholderBinder $placeholderBinder,
34-
HTMLAttributeCollection $htmlAttributeCollection,
35-
ListElementCollection $listElementCollection,
36-
BindableCache $bindableCache,
3727
) {
3828
if($model instanceof HTMLDocument) {
3929
$this->viewModelProcessor = new HTMLDocumentProcessor(
4030
$componentDirectory,
4131
$partialDirectory,
4232
);
43-
44-
$this->initFunction = fn() => $this->initHTMLDocument(
45-
$binder,
46-
$htmlAttributeBinder,
47-
$listBinder,
48-
$tableBinder,
49-
$elementBinder,
50-
$placeholderBinder,
51-
$htmlAttributeCollection,
52-
$listElementCollection,
53-
$bindableCache,
54-
);
5533
}
5634
else {
5735
// TODO: Handle other view model types.
5836
}
5937
}
6038

61-
public function init():void {
62-
$this->initFunction->call($this);
63-
}
64-
65-
private function initHTMLDocument(
39+
public function initHTMLDocument(
6640
DocumentBinder $binder,
6741
HTMLAttributeBinder $htmlAttributeBinder,
6842
ListBinder $listBinder,

src/Logic/LogicExecutor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Gt\WebEngine\Logic;
2+
namespace GT\WebEngine\Logic;
33

44
use Generator;
55
use Gt\Routing\Assembly;

src/Service/ContainerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Gt\WebEngine\Service;
2+
namespace GT\WebEngine\Service;
33

44
use Gt\Config\Config;
55
use Gt\ServiceContainer\Container;

0 commit comments

Comments
 (0)