Skip to content

Commit

Permalink
wip: component binder - tweak order of execution
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Nov 3, 2023
1 parent 818df87 commit c80b25f
Showing 1 changed file with 49 additions and 33 deletions.
82 changes: 49 additions & 33 deletions src/Middleware/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function completeRequestHandling(
$this->handleLogicExecution($this->logicAssembly);

// TODO: Why is this in the handle function?
$documentBinder = $this->serviceContainer->get(DocumentBinder::class);
$documentBinder = $this->serviceContainer->get(Binder::class);
$documentBinder->cleanupDocument();

$this->view->stream($this->viewModel);
Expand Down Expand Up @@ -184,37 +184,8 @@ protected function handleRouting(ServerRequestInterface $request) {
}

protected function handleHTMLDocumentViewModel():void {
$this->serviceContainer->get(HTMLAttributeBinder::class)->setDependencies(
$this->serviceContainer->get(ListBinder::class),
$this->serviceContainer->get(TableBinder::class),
);
$this->serviceContainer->get(ElementBinder::class)->setDependencies(
$this->serviceContainer->get(HTMLAttributeBinder::class),
$this->serviceContainer->get(HTMLAttributeCollection::class),
$this->serviceContainer->get(PlaceholderBinder::class),
);
$this->serviceContainer->get(TableBinder::class)->setDependencies(
$this->serviceContainer->get(ListBinder::class),
$this->serviceContainer->get(ListElementCollection::class),
$this->serviceContainer->get(ElementBinder::class),
$this->serviceContainer->get(HTMLAttributeBinder::class),
$this->serviceContainer->get(HTMLAttributeCollection::class),
$this->serviceContainer->get(PlaceholderBinder::class),
);
$this->serviceContainer->get(ListBinder::class)->setDependencies(
$this->serviceContainer->get(ElementBinder::class),
$this->serviceContainer->get(ListElementCollection::class),
$this->serviceContainer->get(BindableCache::class),
$this->serviceContainer->get(TableBinder::class),
);
$this->serviceContainer->get(Binder::class)->setDependencies(
$this->serviceContainer->get(ElementBinder::class),
$this->serviceContainer->get(PlaceholderBinder::class),
$this->serviceContainer->get(TableBinder::class),
$this->serviceContainer->get(ListBinder::class),
$this->serviceContainer->get(ListElementCollection::class),
$this->serviceContainer->get(BindableCache::class),
);
$expandedLogicAssemblyList = [];
$expandedComponentList = [];

try {
$partial = new PartialContent(implode(DIRECTORY_SEPARATOR, [
Expand All @@ -235,7 +206,8 @@ protected function handleHTMLDocumentViewModel():void {
if(is_file($filePath)) {
$componentAssembly = new Assembly();
$componentAssembly->add($filePath);
$this->handleLogicExecution($componentAssembly, $componentElement);
array_push($expandedLogicAssemblyList, $componentAssembly);
array_push($expandedComponentList, $componentElement);
}
}
}
Expand Down Expand Up @@ -267,6 +239,49 @@ protected function handleHTMLDocumentViewModel():void {
$bodyDirClass .= "--$pathPart";
$this->viewModel->body->classList->add($bodyDirClass);
}

$this->serviceContainer->get(HTMLAttributeBinder::class)->setDependencies(
$this->serviceContainer->get(ListBinder::class),
$this->serviceContainer->get(TableBinder::class),
);
$this->serviceContainer->get(ElementBinder::class)->setDependencies(
$this->serviceContainer->get(HTMLAttributeBinder::class),
$this->serviceContainer->get(HTMLAttributeCollection::class),
$this->serviceContainer->get(PlaceholderBinder::class),
);
$this->serviceContainer->get(TableBinder::class)->setDependencies(
$this->serviceContainer->get(ListBinder::class),
$this->serviceContainer->get(ListElementCollection::class),
$this->serviceContainer->get(ElementBinder::class),
$this->serviceContainer->get(HTMLAttributeBinder::class),
$this->serviceContainer->get(HTMLAttributeCollection::class),
$this->serviceContainer->get(PlaceholderBinder::class),
);
$this->serviceContainer->get(ListBinder::class)->setDependencies(
$this->serviceContainer->get(ElementBinder::class),
$this->serviceContainer->get(ListElementCollection::class),
$this->serviceContainer->get(BindableCache::class),
$this->serviceContainer->get(TableBinder::class),
);
$this->serviceContainer->get(Binder::class)->setDependencies(
$this->serviceContainer->get(ElementBinder::class),
$this->serviceContainer->get(PlaceholderBinder::class),
$this->serviceContainer->get(TableBinder::class),
$this->serviceContainer->get(ListBinder::class),
$this->serviceContainer->get(ListElementCollection::class),
$this->serviceContainer->get(BindableCache::class),
);

// $listElementCollection = $this->serviceContainer->get(ListElementCollection::class);
// var_dump($listElementCollection);die();

foreach($expandedLogicAssemblyList as $i => $assembly) {
$componentElement = $expandedComponentList[$i];
if(!$componentElement) {
var_dump($assembly);die();
}
$this->handleLogicExecution($assembly, $componentElement);
}
}

protected function handleSession():void {
Expand Down Expand Up @@ -368,6 +383,7 @@ protected function handleLogicExecution(Assembly $logicAssembly, ?Element $compo
);
$binder->setComponentBinderDependencies($component);
$extraArgs[Binder::class] = $binder;
$extraArgs[Element::class] = $component;
}

foreach($logicExecutor->invoke("go_before", $extraArgs) as $file) {
Expand Down

0 comments on commit c80b25f

Please sign in to comment.