Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c7235a192 | |||
| d7e5a82e8a | |||
| 1198934b2b | |||
| 52cb55e360 | |||
| 24a8d0f876 |
@@ -0,0 +1,3 @@
|
|||||||
|
composer.lock
|
||||||
|
/nbproject/
|
||||||
|
/vendor/
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "potter/datatable",
|
||||||
|
"type": "library",
|
||||||
|
"license": "MIT",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Potter\\": "src/Potter/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jay Potter",
|
||||||
|
"email": "j@ypotter.ca"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"require": {
|
||||||
|
"datatables/datatables": "^1.10.21",
|
||||||
|
"potter/container": ">=0.0.1",
|
||||||
|
"potter/controller": ">=0.0.1",
|
||||||
|
"potter/response": ">=0.0.1",
|
||||||
|
"potter/router": ">=0.0.1",
|
||||||
|
"psr/http-message": "^1.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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