1
1
<?php
2
-
3
2
namespace Ajax \service ;
4
3
5
-
6
4
use Ajax \JsUtils ;
5
+
7
6
class AjaxCall {
7
+
8
8
private $ method ;
9
+
9
10
private $ parameters ;
10
11
11
12
public function __construct ($ method , $ parameters ) {
12
- $ this ->method = $ method ;
13
- $ this ->parameters = $ parameters ;
13
+ $ this ->method = $ method ;
14
+ $ this ->parameters = $ parameters ;
14
15
}
15
16
16
- public function compile (JsUtils $ js= null ) {
17
- if ($ js ===null )
17
+ public function compile (JsUtils $ js = null ) {
18
+ if ($ js === null )
18
19
return ;
19
- $ params= "{} " ;
20
- $ stopPropagation= true ;
21
- $ preventDefault= true ;
22
- $ method= "get " ;
23
- $ this ->parameters ["immediatly " ]= false ;
20
+ $ params = "{} " ;
21
+ $ stopPropagation = true ;
22
+ $ preventDefault = true ;
23
+ $ method = "get " ;
24
+ $ this ->parameters ["immediatly " ] = false ;
24
25
extract ($ this ->parameters );
25
- $ result= $ this ->_eventPreparing ($ preventDefault , $ stopPropagation );
26
- switch ($ this ->method ) {
26
+ $ result = $ this ->_eventPreparing ($ preventDefault , $ stopPropagation );
27
+ switch ($ this ->method ) {
27
28
case "get " :
28
- $ result.= $ js ->getDeferred ($ url , $ responseElement , $ this ->parameters );
29
+ $ result .= $ js ->getDeferred ($ url , $ responseElement , $ this ->parameters );
29
30
break ;
30
31
case "post " :
31
- $ result.= $ js ->postDeferred ($ url , $ params ,$ responseElement , $ this ->parameters );
32
+ $ result .= $ js ->postDeferred ($ url , $ params , $ responseElement , $ this ->parameters );
32
33
break ;
33
34
case "postForm " :
34
- $ result.= $ js ->postFormDeferred ($ url , $ form , $ responseElement , $ this ->parameters );
35
+ $ result .= $ js ->postFormDeferred ($ url , $ form , $ responseElement , $ this ->parameters );
35
36
break ;
36
37
case "json " :
37
- $ result.= $ js ->jsonDeferred ($ url ,$ method ,$ this ->parameters );
38
+ $ result .= $ js ->jsonDeferred ($ url , $ method , $ this ->parameters );
38
39
break ;
39
40
case "jsonArray " :
40
- $ result.= $ js ->jsonArrayDeferred ($ modelSelector , $ url ,$ method ,$ this ->parameters );
41
+ $ result .= $ js ->jsonArrayDeferred ($ modelSelector , $ url , $ method , $ this ->parameters );
41
42
break ;
42
43
default :
44
+ $ result .= $ js ->ajaxDeferred ($ this ->method , $ url , $ responseElement , $ this ->parameters );
43
45
break ;
44
46
}
45
47
return $ result ;
46
48
}
47
49
48
- protected function _eventPreparing ($ preventDefault ,$ stopPropagation ){
49
- $ result= "" ;
50
- if ($ preventDefault ===true ) {
51
- $ result.= Javascript::$ preventDefault ;
50
+ protected function _eventPreparing ($ preventDefault , $ stopPropagation ) {
51
+ $ result = "" ;
52
+ if ($ preventDefault === true ) {
53
+ $ result .= Javascript::$ preventDefault ;
52
54
}
53
- if ($ stopPropagation ===true ) {
54
- $ result.= Javascript::$ stopPropagation ;
55
+ if ($ stopPropagation === true ) {
56
+ $ result .= Javascript::$ stopPropagation ;
55
57
}
56
58
return $ result ;
57
59
}
@@ -61,7 +63,7 @@ public function getMethod() {
61
63
}
62
64
63
65
public function setMethod ($ method ) {
64
- $ this ->method = $ method ;
66
+ $ this ->method = $ method ;
65
67
return $ this ;
66
68
}
67
69
@@ -70,7 +72,7 @@ public function getParameters() {
70
72
}
71
73
72
74
public function setParameters ($ parameters ) {
73
- $ this ->parameters = $ parameters ;
75
+ $ this ->parameters = $ parameters ;
74
76
return $ this ;
75
77
}
76
78
}
0 commit comments