11<?php
2-
32namespace Ajax \service ;
43
5-
64use Ajax \JsUtils ;
5+
76class AjaxCall {
7+
88 private $ method ;
9+
910 private $ parameters ;
1011
1112 public function __construct ($ method , $ parameters ) {
12- $ this ->method = $ method ;
13- $ this ->parameters = $ parameters ;
13+ $ this ->method = $ method ;
14+ $ this ->parameters = $ parameters ;
1415 }
1516
16- public function compile (JsUtils $ js= null ) {
17- if ($ js ===null )
17+ public function compile (JsUtils $ js = null ) {
18+ if ($ js === null )
1819 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 ;
2425 extract ($ this ->parameters );
25- $ result= $ this ->_eventPreparing ($ preventDefault , $ stopPropagation );
26- switch ($ this ->method ) {
26+ $ result = $ this ->_eventPreparing ($ preventDefault , $ stopPropagation );
27+ switch ($ this ->method ) {
2728 case "get " :
28- $ result.= $ js ->getDeferred ($ url , $ responseElement , $ this ->parameters );
29+ $ result .= $ js ->getDeferred ($ url , $ responseElement , $ this ->parameters );
2930 break ;
3031 case "post " :
31- $ result.= $ js ->postDeferred ($ url , $ params ,$ responseElement , $ this ->parameters );
32+ $ result .= $ js ->postDeferred ($ url , $ params , $ responseElement , $ this ->parameters );
3233 break ;
3334 case "postForm " :
34- $ result.= $ js ->postFormDeferred ($ url , $ form , $ responseElement , $ this ->parameters );
35+ $ result .= $ js ->postFormDeferred ($ url , $ form , $ responseElement , $ this ->parameters );
3536 break ;
3637 case "json " :
37- $ result.= $ js ->jsonDeferred ($ url ,$ method ,$ this ->parameters );
38+ $ result .= $ js ->jsonDeferred ($ url , $ method , $ this ->parameters );
3839 break ;
3940 case "jsonArray " :
40- $ result.= $ js ->jsonArrayDeferred ($ modelSelector , $ url ,$ method ,$ this ->parameters );
41+ $ result .= $ js ->jsonArrayDeferred ($ modelSelector , $ url , $ method , $ this ->parameters );
4142 break ;
4243 default :
44+ $ result .= $ js ->ajaxDeferred ($ this ->method , $ url , $ responseElement , $ this ->parameters );
4345 break ;
4446 }
4547 return $ result ;
4648 }
4749
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 ;
5254 }
53- if ($ stopPropagation ===true ) {
54- $ result.= Javascript::$ stopPropagation ;
55+ if ($ stopPropagation === true ) {
56+ $ result .= Javascript::$ stopPropagation ;
5557 }
5658 return $ result ;
5759 }
@@ -61,7 +63,7 @@ public function getMethod() {
6163 }
6264
6365 public function setMethod ($ method ) {
64- $ this ->method = $ method ;
66+ $ this ->method = $ method ;
6567 return $ this ;
6668 }
6769
@@ -70,7 +72,7 @@ public function getParameters() {
7072 }
7173
7274 public function setParameters ($ parameters ) {
73- $ this ->parameters = $ parameters ;
75+ $ this ->parameters = $ parameters ;
7476 return $ this ;
7577 }
7678}
0 commit comments