Skip to content

Commit

Permalink
use template middleware as system
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayIterator committed Oct 15, 2023
1 parent 6dd0a3e commit 3af8497
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 65 deletions.
53 changes: 0 additions & 53 deletions SubModules/Templates/Middlewares/TemplateLoaderMiddleware.php

This file was deleted.

23 changes: 11 additions & 12 deletions SubModules/Templates/Templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

use ArrayAccess\TrayDigita\App\Modules\Core\Abstracts\CoreSubmoduleAbstract;
use ArrayAccess\TrayDigita\App\Modules\Core\SubModules\Option\Option;
use ArrayAccess\TrayDigita\App\Modules\Core\SubModules\Templates\Middlewares\TemplateLoaderMiddleware;
use ArrayAccess\TrayDigita\Kernel\Interfaces\KernelInterface;
use ArrayAccess\TrayDigita\Templates\Middlewares\TemplateLoaderMiddleware;
use ArrayAccess\TrayDigita\Templates\Wrapper;
use ArrayAccess\TrayDigita\Util\Filter\ContainerHelper;
use ArrayAccess\TrayDigita\View\Interfaces\ViewInterface;
Expand Down Expand Up @@ -66,7 +66,7 @@ private function initSetTemplate(KernelInterface $kernel): void
}
$this->templateRule = new TemplateRule($wrapper);
$this->templateRule->initialize();
$view?->setTemplateRule($this->templateRule);
$view->setTemplateRule($this->templateRule);

$option = $this->getModules()->get(Option::class);
$active = $option?->get(self::ACTIVE_TEMPLATE_KEY)?->getValue();
Expand All @@ -81,15 +81,14 @@ private function initSetTemplate(KernelInterface $kernel): void
$view->setViewsDirectory([]);
}

// add middleware to load templates.php
try {
$kernel->getHttpKernel()->addMiddleware(
ContainerHelper::resolveCallable(
TemplateLoaderMiddleware::class,
$this->getContainer()
)
);
} catch (Throwable $e) {
}
/**
* add middleware to load templates.php
* @see TemplateLoaderMiddleware::doProcess()
*/
$kernel->getHttpKernel()->addMiddleware(
new TemplateLoaderMiddleware(
$view->getContainer()??$this->getContainer()
)
);
}
}

0 comments on commit 3af8497

Please sign in to comment.