1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpenSkill\Datatable\Versions; |
4
|
|
|
|
5
|
|
|
use OpenSkill\Datatable\Columns\ColumnConfiguration; |
6
|
|
|
use OpenSkill\Datatable\Data\ResponseData; |
7
|
|
|
use OpenSkill\Datatable\Queries\QueryConfiguration; |
8
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
10
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Version |
14
|
|
|
* @package OpenSkill\Datatable\Versions |
15
|
|
|
* |
16
|
|
|
* Base interface that is used to support different frontend views from this data table plugin |
17
|
|
|
*/ |
18
|
|
|
abstract class Version |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var RequestStack |
22
|
|
|
*/ |
23
|
|
|
protected $requestStack; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Version constructor. |
27
|
|
|
*/ |
28
|
|
|
public function __construct(RequestStack $requestStack) |
29
|
|
|
{ |
30
|
|
|
$this->requestStack = $requestStack; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Method to determine if this parser can handle the query parameters. If so then the parser should return true |
35
|
|
|
* and be able to return a DTQueryConfiguration |
36
|
|
|
* |
37
|
|
|
* @return bool true if the parser is able to parse the query parameters and to return a DTQueryConfiguration |
38
|
|
|
*/ |
39
|
|
|
abstract public function canParseRequest(); |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Method that should parse the request and return a DTQueryConfiguration |
43
|
|
|
* |
44
|
|
|
* @param ColumnConfiguration[] $columnConfiguration The configuration of the columns |
45
|
|
|
* @return QueryConfiguration the configuration the provider can use to prepare the data |
46
|
|
|
*/ |
47
|
|
|
abstract public function parseRequest(array $columnConfiguration); |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Is responsible to take the generated data and prepare a response for it. |
52
|
|
|
* @param ResponseData $data The processed data. |
53
|
|
|
* @param QueryConfiguration $queryConfiguration the query configuration for the current request. |
54
|
|
|
* @param ColumnConfiguration[] $columnConfigurations the column configurations for the current data table. |
55
|
|
|
* @return JsonResponse the response that should be returned to the client. |
56
|
|
|
*/ |
57
|
|
|
abstract public function createResponse( |
58
|
|
|
ResponseData $data, |
59
|
|
|
QueryConfiguration $queryConfiguration, |
60
|
|
|
array $columnConfigurations |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string The name of the view that this version should use fot the table. |
65
|
|
|
*/ |
66
|
|
|
abstract public function tableView(); |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string The name of the view that this version should use for the script. |
70
|
|
|
*/ |
71
|
|
|
abstract public function scriptView(); |
72
|
|
|
} |