|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the jquery-datatables-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\JQuery\DataTablesBundle\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use WBW\Bundle\BootstrapBundle\Controller\AbstractBootstrapController; |
|
15
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\API\DataTablesWrapper; |
|
16
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Exception\UnregisteredDataTablesProviderException; |
|
17
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Manager\DataTablesManager; |
|
18
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\Provider\DataTablesProviderInterface; |
|
19
|
|
|
use WBW\Library\Core\IO\HTTPInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* AbstractDataTablesController. |
|
23
|
|
|
* |
|
24
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
25
|
|
|
* @package WBW\Bundle\JQuery\DataTablesBundle\Controller |
|
26
|
|
|
*/ |
|
27
|
|
|
abstract class AbstractDataTablesController extends AbstractBootstrapController { |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Get the DataTables provider. |
|
31
|
|
|
* |
|
32
|
|
|
* @return DataTablesProviderInterface Returns the DataTables provider. |
|
33
|
|
|
* @throws UnregisteredDataTablesProviderException Throws an unregistered DataTables provider exception. |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function getDataTablesProvider($name) { |
|
36
|
|
|
|
|
37
|
|
|
// Log a debug trace. |
|
38
|
|
|
$this->getLogger()->debug(sprintf("DataTables controller search for a DataTables provider with name \"%s\"", $name)); |
|
39
|
|
|
|
|
40
|
|
|
// Get the DataTables provider. |
|
41
|
|
|
$dtProvider = $this->get(DataTablesManager::SERVICE_NAME)->getProvider($name); |
|
42
|
|
|
|
|
43
|
|
|
// Log an info trace. |
|
44
|
|
|
$this->getLogger()->info(sprintf("DataTables controller found a DataTables provider with name \"%s\"", $name)); |
|
45
|
|
|
|
|
46
|
|
|
// Return the DataTables provider. |
|
47
|
|
|
return $dtProvider; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get a DataTables wrapper. |
|
52
|
|
|
* |
|
53
|
|
|
* @param DataTablesProviderInterface $dtProvider The DataTables provider. |
|
54
|
|
|
* @return DataTablesWrapper Returns the DataTables wrapper. |
|
55
|
|
|
*/ |
|
56
|
|
|
protected function getDataTablesWrapper(DataTablesProviderInterface $dtProvider) { |
|
57
|
|
|
|
|
58
|
|
|
// Initialize the DataTables wrapper. |
|
59
|
|
|
$dtWrapper = new DataTablesWrapper($dtProvider->getPrefix(), HTTPInterface::HTTP_METHOD_POST, $this->getRouter()->generate("jquery_datatables_index", ["name" => $dtProvider->getName()])); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
// Handle each column. |
|
62
|
|
|
foreach ($dtProvider->getColumns() as $dtColumn) { |
|
63
|
|
|
|
|
64
|
|
|
// Log a debug trace. |
|
65
|
|
|
$this->getLogger()->debug(sprintf("DataTables provider add a DataTables column \"%s\"", $dtColumn->getData())); |
|
66
|
|
|
|
|
67
|
|
|
// Add. |
|
68
|
|
|
$dtWrapper->addColumn($dtColumn); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
// Return the DataTables wrapper. |
|
72
|
|
|
return $dtWrapper; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Get the notification. |
|
77
|
|
|
* |
|
78
|
|
|
* @param string $id The notification id. |
|
79
|
|
|
* @return string Returns the notification. |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function getNotification($id) { |
|
82
|
|
|
return $this->getTranslator()->trans($id, [], "JQueryDataTablesBundle"); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.