add Bootstrap

This commit is contained in:
2026-08-14 18:16:40 -04:00
parent 83964eb9fd
commit 85a158c435
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Potter;
use \Potter\Response\Text,
\Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
final class Bootstrap extends Controller
{
static private function getBootstrapScript(ServerRequestInterface $request): ResponseInterface
{
return new Text(
text: file_get_contents(getcwd() . '/vendor/twbs/bootstrap/dist/jss/bootstrap.js'),
headers: ['Content-Type' => ['application/javascript; charset=utf-8']]);
}
static private function getBootstrapStyle(ServerRequestInterface $request): ResponseInterface
{
return new Text(
text: file_get_contents(getcwd() . '/vendor/twbs/bootstrap/dist/jss/bootstrap.js'),
headers: ['Content-Type' => ['text/css; charset=utf-8']]);
}
static private function mapRoutes(Container $container, \Potter\Router\Router $router): void
{
$router->map('GET', '/bootstrap.js', [self::class, 'getBootstrapScript']);
$router->map('GET', '/bootstrap.css', [self::class, 'getBootstrapStyle']);
}
}