add Bootstrap
This commit is contained in:
@@ -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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user