Skip to content

Commit 017cb5e

Browse files
committed
AjaxCall complexity reduction
1 parent 5db14f7 commit 017cb5e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Ajax/service/AjaxCall.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public function __construct($method, $parameters) {
1616
public function compile(JsUtils $js=null) {
1717
if ($js==null)
1818
return;
19-
$result="";
2019
$params="{}";
2120
$jsCallback=NULL;
2221
$attr="id";
@@ -28,12 +27,7 @@ public function compile(JsUtils $js=null) {
2827
$hasLoader=true;
2928
$method="get";
3029
extract($this->parameters);
31-
if ($preventDefault===true) {
32-
$result.=Javascript::$preventDefault;
33-
}
34-
if ($stopPropagation===true) {
35-
$result.=Javascript::$stopPropagation;
36-
}
30+
$result=$this->_evenPreparing($preventDefault, $stopPropagation);
3731
switch($this->method) {
3832
case "get":
3933
$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition);
@@ -54,6 +48,17 @@ public function compile(JsUtils $js=null) {
5448
return $result;
5549
}
5650

51+
protected function _evenPreparing($preventDefault,$stopPropagation){
52+
$result="";
53+
if ($preventDefault===true) {
54+
$result.=Javascript::$preventDefault;
55+
}
56+
if ($stopPropagation===true) {
57+
$result.=Javascript::$stopPropagation;
58+
}
59+
return $result;
60+
}
61+
5762
public function getMethod() {
5863
return $this->method;
5964
}

0 commit comments

Comments
 (0)