add Datatable
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Potter;
|
||||||
|
|
||||||
|
use \Potter\Response\Text;
|
||||||
|
use \Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
|
||||||
|
|
||||||
|
final class Datatable extends Controller
|
||||||
|
{
|
||||||
|
public function getDatatableScript(ServerRequestInterface $request): ResponseInterface
|
||||||
|
{
|
||||||
|
return new Text(
|
||||||
|
text: file_get_contents(getcwd() . '/vendor/datatables/datatables/media/js/jquery.dataTables.js'),
|
||||||
|
headers: ['Content-Type' => ['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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user