Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 5e4bf48

Browse files
Rename type to method in Ajax
Rename type to method
2 parents 42ef873 + ab1213a commit 5e4bf48

File tree

6 files changed

+36
-19
lines changed

6 files changed

+36
-19
lines changed

Datatable/Ajax.php

+30-10
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Ajax
4343
*
4444
* @var string
4545
*/
46-
protected $type;
46+
protected $method;
4747

4848
/**
4949
* Data to be sent.
@@ -90,17 +90,17 @@ public function configureOptions(OptionsResolver $resolver)
9090
{
9191
$resolver->setDefaults(array(
9292
'url' => null,
93-
'type' => 'GET',
93+
'method' => 'GET',
9494
'data' => null,
9595
'pipeline' => 0,
9696
));
9797

9898
$resolver->setAllowedTypes('url', array('null', 'string'));
99-
$resolver->setAllowedTypes('type', 'string');
99+
$resolver->setAllowedTypes('method', 'string');
100100
$resolver->setAllowedTypes('data', array('null', 'array'));
101101
$resolver->setAllowedTypes('pipeline', 'int');
102102

103-
$resolver->setAllowedValues('type', array('GET', 'POST'));
103+
$resolver->setAllowedValues('method', array('GET', 'POST'));
104104

105105
return $this;
106106
}
@@ -134,29 +134,49 @@ public function setUrl($url)
134134
}
135135

136136
/**
137-
* Get type.
137+
* Get method.
138138
*
139139
* @return string
140140
*/
141+
public function getMethod()
142+
{
143+
return $this->method;
144+
}
145+
146+
/**
147+
* @return string
148+
* @deprecated Use getMethod() instead
149+
*/
141150
public function getType()
142151
{
143-
return $this->type;
152+
return $this->getMethod();
144153
}
145154

146155
/**
147-
* Set type.
156+
* Set method.
148157
*
149-
* @param string $type
158+
* @param string $method
150159
*
151160
* @return $this
152161
*/
153-
public function setType($type)
162+
public function setMethod($method)
154163
{
155-
$this->type = $type;
164+
$this->method = $method;
156165

157166
return $this;
158167
}
159168

169+
/**
170+
* @param $method
171+
*
172+
* @return \Sg\DatatablesBundle\Datatable\Ajax
173+
* @deprecated Use setMethod() instead
174+
*/
175+
public function setType($method)
176+
{
177+
return $this->setMethod($method);
178+
}
179+
160180
/**
161181
* Get data.
162182
*

Resources/public/js/pipeline.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $.fn.dataTable.pipeline = function ( opts ) {
55
url: '', // script url
66
data: null, // function or object with parameters to send to the server
77
// matching how `ajax.data` works in DataTables
8-
method: 'GET' // Ajax HTTP method
8+
method: opts.method // Ajax HTTP method
99
}, opts );
1010

1111
// Private variables for storing the cache
@@ -73,7 +73,7 @@ $.fn.dataTable.pipeline = function ( opts ) {
7373
}
7474

7575
settings.jqXHR = $.ajax( {
76-
"type": conf.method,
76+
"method": conf.method,
7777
"url": conf.url,
7878
"data": request,
7979
"dataType": "json",

Resources/views/datatable/ajax.html.twig

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% if sg_datatables_view.ajax.url is not same as(null) %}
1111
"url": "{{ sg_datatables_view.ajax.url|raw }}",
1212
{% endif %}
13-
"type": "{{ sg_datatables_view.ajax.type }}",
13+
"method": "{{ sg_datatables_view.ajax.method }}",
1414
{% if sg_datatables_view.ajax.data is not same as(null) %}
1515
"data": {{ sg_datatables_view.ajax.data|raw }},
1616
{% endif %}
@@ -27,6 +27,3 @@
2727
{{ ajax_vars }}
2828
},
2929
{% endif %}
30-
31-
32-

Resources/views/datatable/multiselect_actions.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ $(".sg-datatables-{{ datatable_name }}-multiselect-action").on("click", function
162162
if (url != null) {
163163
$.ajax({
164164
url: url,
165-
type: "POST",
165+
method: "POST",
166166
cache: false,
167167
data: {
168168
'data': items,

Response/DatatableResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private function createDatatableQueryBuilder()
193193
private function getRequestParams()
194194
{
195195
$parameterBag = null;
196-
$type = $this->datatable->getAjax()->getType();
196+
$type = $this->datatable->getAjax()->getMethod();
197197

198198
if ('GET' === strtoupper($type)) {
199199
$parameterBag = $this->request->query;

Tests/Datatables/PostDatatable.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function buildDatatable(array $options = array())
2828
{
2929
$this->ajax->set(array(
3030
'url' => '',
31-
'type' => 'GET',
31+
'method' => 'GET',
3232
));
3333

3434
$this->options->set(array(

0 commit comments

Comments
 (0)