diff --git a/src/Potter/Datatable.php b/src/Potter/Datatable.php new file mode 100644 index 0000000..92a81c3 --- /dev/null +++ b/src/Potter/Datatable.php @@ -0,0 +1,39 @@ + ['application/javascript; charset=utf-8']]); + } + + public function getDatatableStyle(ServerRequestInterface $request): ResponseInterface + { + return new Text( + text: file_get_contents(getcwd() . '/vendor/datatables/datatables/media/css/jquery.dataTables.css'), + headers: ['Content-Type' => ['text/css; charset=utf-8']]); + } + + public function getJQueryScript(ServerRequestInterface $request): ResponseInterface + { + return new Text( + text: file_get_contents(getcwd() . '/vendor/datatables/datatables/media/js/jquery.js'), + headers: ['Content-Type' => ['application/javascript; charset=utf-8']]); + } + + protected function mapRoutes(Container $container, \Potter\Router\Router $router): void + { + $router->map('GET', '/datatable.js', [$this, 'getDatatableScript']); + $router->map('GET', '/datatable.css', [$this, 'getDatatableStyle']); + $router->map('GET', '/jquery.js', [$this, 'getJQueryScript']); + } +}