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\Helper; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\API\DataTablesWrapper; |
15
|
|
|
use WBW\Bundle\JQuery\DataTablesBundle\JQueryDataTablesBundle; |
16
|
|
|
use WBW\Library\Core\Argument\ObjectHelper; |
17
|
|
|
use WBW\Library\Core\Argument\StringHelper; |
18
|
|
|
use WBW\Library\Core\Exception\IO\FileNotFoundException; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* DataTables wrapper helper. |
22
|
|
|
* |
23
|
|
|
* @author webeweb <https://github.com/webeweb/> |
24
|
|
|
* @package WBW\Bundle\JQuery\DataTablesBundle\Helper |
25
|
|
|
*/ |
26
|
|
|
class DataTablesWrapperHelper { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Get a language URL. |
30
|
|
|
* |
31
|
|
|
* @param string $language The language. |
32
|
|
|
* @return string Returns the language URL. |
33
|
|
|
* @throws FileNotFoundException Throws a file not found exception if the language file does not exist. |
34
|
|
|
*/ |
35
|
|
|
public static function getLanguageURL($language) { |
36
|
|
|
|
37
|
|
|
// Initialize the directory. |
38
|
|
|
$dir = ObjectHelper::getDirectory(JQueryDataTablesBundle::class); |
|
|
|
|
39
|
|
|
$dir .= "/Resources/public/datatables-i18n-%version%/%language%.json"; |
40
|
|
|
|
41
|
|
|
// Initialize the URI. |
42
|
|
|
$uri = "/bundles/jquerydatatables/datatables-i18n-%version%/%language%.json"; |
43
|
|
|
|
44
|
|
|
// Initialize the URL. |
45
|
|
|
$url = StringHelper::replace($uri, ["%version%", "%language%"], [JQueryDataTablesBundle::DATATABLES_VERSION, $language]); |
46
|
|
|
|
47
|
|
|
// Initialize and check the filename. |
48
|
|
|
$file = StringHelper::replace($dir, ["%version%", "%language%"], [JQueryDataTablesBundle::DATATABLES_VERSION, $language]); |
49
|
|
|
if (false === file_exists($file)) { |
50
|
|
|
throw new FileNotFoundException($url); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
// Return the URL. |
54
|
|
|
return $url; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get a name. |
59
|
|
|
* |
60
|
|
|
* @param DataTablesWrapper $dtWrapper The wrapper. |
61
|
|
|
* @return string Returns the name. |
62
|
|
|
*/ |
63
|
|
|
public static function getName(DataTablesWrapper $dtWrapper) { |
64
|
|
|
return "dt" . preg_replace("/[^A-Za-z0-9]/", "", $dtWrapper->getName()); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get a options. |
69
|
|
|
* |
70
|
|
|
* @param DataTablesWrapper $dtWrapper The wrapper. |
71
|
|
|
* @return array Returns the options. |
72
|
|
|
*/ |
73
|
|
|
public static function getOptions(DataTablesWrapper $dtWrapper) { |
74
|
|
|
|
75
|
|
|
// Initialize the output. |
76
|
|
|
$output = []; |
77
|
|
|
|
78
|
|
|
// Check the options. |
79
|
|
|
if (null !== $dtWrapper->getOptions()) { |
80
|
|
|
$output = $dtWrapper->getOptions()->getOptions(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
// Set the options. |
84
|
|
|
$output["ajax"] = []; |
85
|
|
|
$output["ajax"]["type"] = $dtWrapper->getMethod(); |
86
|
|
|
$output["ajax"]["url"] = $dtWrapper->getUrl(); |
87
|
|
|
$output["columns"] = []; |
88
|
|
|
$output["order"] = []; |
89
|
|
|
$output["processing"] = $dtWrapper->getProcessing(); |
90
|
|
|
$output["serverSide"] = $dtWrapper->getServerSide(); |
91
|
|
|
|
92
|
|
|
// Handle each column. |
93
|
|
|
foreach ($dtWrapper->getColumns() as $current) { |
94
|
|
|
$output["columns"][] = $current->toArray(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
// Handle each order. |
98
|
|
|
foreach ($dtWrapper->getOrder() as $current) { |
99
|
|
|
$output["order"][] = $current->toArray(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
// Return the output. |
103
|
|
|
return $output; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
} |
107
|
|
|
|
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.