Skip to content

Commit

Permalink
added Presenter::findTemplateFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 27, 2023
1 parent 85e0340 commit dca911e
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,21 +469,26 @@ public function sendTemplate(?Template $template = null): void
{
$template = $template ?? $this->getTemplate();
if (!$template->getFile()) {
$files = $this->formatTemplateFiles();
foreach ($files as $file) {
if (is_file($file)) {
$template->setFile($file);
break;
}
}
$template->setFile($this->findTemplateFile());
}
$this->sendResponse(new Responses\TextResponse($template));
}


if (!$template->getFile()) {
$file = strtr(Arrays::first($files), '/', DIRECTORY_SEPARATOR);
$this->error("Page not found. Missing template '$file'.");
/**
* Finds template file name.
*/
public function findTemplateFile(): string
{
$files = $this->formatTemplateFiles();
foreach ($files as $file) {
if (is_file($file)) {
return $file;
}
}

$this->sendResponse(new Responses\TextResponse($template));
$file = strtr(Arrays::first($files), '/', DIRECTORY_SEPARATOR);
$this->error("Page not found. Missing template '$file'.");
}


Expand Down

0 comments on commit dca911e

Please sign in to comment.