implement texts view method
This commit is contained in:
parent
019f3a61e1
commit
d4e31baed0
1 changed files with 21 additions and 0 deletions
|
|
@ -2,10 +2,15 @@
|
||||||
|
|
||||||
namespace App\View;
|
namespace App\View;
|
||||||
|
|
||||||
|
use App\Text\TextRepository;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
|
||||||
class ViewController
|
class ViewController
|
||||||
{
|
{
|
||||||
|
public function __construct(
|
||||||
|
private TextRepository $textRepository,
|
||||||
|
) {}
|
||||||
|
|
||||||
public function admin(Response $response): Response
|
public function admin(Response $response): Response
|
||||||
{
|
{
|
||||||
$html = file_get_contents(__DIR__.'/../../views/templates/admin.php', true);
|
$html = file_get_contents(__DIR__.'/../../views/templates/admin.php', true);
|
||||||
|
|
@ -13,4 +18,20 @@ class ViewController
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function texts(Response $response): Response
|
||||||
|
{
|
||||||
|
$texts = $this->textRepository->getAll();
|
||||||
|
|
||||||
|
$textsList = '';
|
||||||
|
foreach ($texts as $text) {
|
||||||
|
$textsList .= '<li>' . htmlspecialchars($text->getName()) . '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = file_get_contents(__DIR__.'/../../views/templates/texts.php', true);
|
||||||
|
$html = str_replace('{{texts}}', $textsList, $html);
|
||||||
|
$response->getBody()->write($html);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue