Completed
Push — master ( 5e2c18...7ed867 )
by Jean-Christophe
02:42
created
Ajax/php/symfony/JsUtils.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 namespace Ajax\php\symfony;
4 4
 
5 5
 
6
-use Symfony\Component\HttpFoundation\Request;
7 6
 use Symfony\Component\HttpKernel\HttpKernelInterface;
8 7
 use Ajax\service\JString;
9 8
 class JsUtils extends \Ajax\JsUtils{
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,44 +6,44 @@  discard block
 block discarded – undo
6 6
 use Symfony\Component\HttpFoundation\Request;
7 7
 use Symfony\Component\HttpKernel\HttpKernelInterface;
8 8
 use Ajax\service\JString;
9
-class JsUtils extends \Ajax\JsUtils{
9
+class JsUtils extends \Ajax\JsUtils {
10 10
 
11
-	public function getUrl($url){
11
+	public function getUrl($url) {
12 12
 		$router=$this->getInjected();
13
-		if(isset($router)){
13
+		if (isset($router)) {
14 14
 			try {
15 15
 				$url=$router->generate($url);
16
-			}catch (\Exception $e){
16
+			}catch (\Exception $e) {
17 17
 				return $url;
18 18
 			}
19 19
 		}
20 20
 		return $url;
21 21
 	}
22
-	public function addViewElement($identifier,$content,&$view){
23
-		if(\is_array($view)){
24
-			if(\array_key_exists("q", $view)===false){
22
+	public function addViewElement($identifier, $content, &$view) {
23
+		if (\is_array($view)) {
24
+			if (\array_key_exists("q", $view)===false) {
25 25
 				$view["q"]=array();
26 26
 			}
27 27
 			$view["q"][$identifier]=$content;
28
-		}elseif($view instanceof \Twig_Environment){
28
+		}elseif ($view instanceof \Twig_Environment) {
29 29
 			$vars=$view->getGlobals();
30
-			if(\array_key_exists("q", $vars)===false){
30
+			if (\array_key_exists("q", $vars)===false) {
31 31
 				$vars["q"]=array();
32 32
 			}
33 33
 			$vars["q"][$identifier]=$content;
34
-			$view->addGlobal("q",$vars["q"]);
34
+			$view->addGlobal("q", $vars["q"]);
35 35
 		}
36 36
 	}
37 37
 
38
-	public function createScriptVariable(&$view,$view_var, $output){
38
+	public function createScriptVariable(&$view, $view_var, $output) {
39 39
 		$this->addVariable($view_var, $output, $view);
40 40
 	}
41 41
 
42
-	protected function addVariable($key,$value,&$view){
43
-		if(\is_array($view)){
42
+	protected function addVariable($key, $value, &$view) {
43
+		if (\is_array($view)) {
44 44
 			$view[$key]=$value;
45
-		}elseif($view instanceof \Twig_Environment){
46
-			$view->addGlobal($key,$value);
45
+		}elseif ($view instanceof \Twig_Environment) {
46
+			$view->addGlobal($key, $value);
47 47
 		}
48 48
 	}
49 49
 
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 	 * @param array $params
55 55
 	 * @see \Ajax\JsUtils::forward()
56 56
 	 */
57
-	public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){
57
+	public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) {
58 58
 		$path=$params;
59
-		$request = $initialControllerInstance->get('request_stack')->getCurrentRequest();
60
-		$path['_forwarded'] = $request->attributes;
61
-		$path['_controller'] = $controllerName.":".$actionName;
62
-		$subRequest = $request->duplicate([], null, $path);
63
-		$response= $initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
59
+		$request=$initialControllerInstance->get('request_stack')->getCurrentRequest();
60
+		$path['_forwarded']=$request->attributes;
61
+		$path['_controller']=$controllerName.":".$actionName;
62
+		$subRequest=$request->duplicate([], null, $path);
63
+		$response=$initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
64 64
 		return $response->getContent();
65 65
 	}
66 66
 
67
-	public function renderContent($initialControllerInstance,$viewName, $params=NULL) {
67
+	public function renderContent($initialControllerInstance, $viewName, $params=NULL) {
68 68
 		if ($initialControllerInstance->has('templating')) {
69 69
 			return $initialControllerInstance->get('templating')->render($viewName, $params);
70 70
 		}
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 		return $initialControllerInstance->get('twig')->render($viewName, $params);
77 77
 	}
78 78
 
79
-	public function fromDispatcher($dispatcher){
80
-		$request = $dispatcher->get('request_stack')->getCurrentRequest();
79
+	public function fromDispatcher($dispatcher) {
80
+		$request=$dispatcher->get('request_stack')->getCurrentRequest();
81 81
 		$uri=$request->getPathInfo();
82
-		if(JString::startswith($uri, "/")){
82
+		if (JString::startswith($uri, "/")) {
83 83
 			$uri=\substr($uri, 1);
84 84
 		}
85 85
 		return \explode("/", $uri);
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		if(isset($router)){
14 14
 			try {
15 15
 				$url=$router->generate($url);
16
-			}catch (\Exception $e){
16
+			} catch (\Exception $e){
17 17
 				return $url;
18 18
 			}
19 19
 		}
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 				$view["q"]=array();
26 26
 			}
27 27
 			$view["q"][$identifier]=$content;
28
-		}elseif($view instanceof \Twig_Environment){
28
+		} elseif($view instanceof \Twig_Environment){
29 29
 			$vars=$view->getGlobals();
30 30
 			if(\array_key_exists("q", $vars)===false){
31 31
 				$vars["q"]=array();
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	protected function addVariable($key,$value,&$view){
43 43
 		if(\is_array($view)){
44 44
 			$view[$key]=$value;
45
-		}elseif($view instanceof \Twig_Environment){
45
+		} elseif($view instanceof \Twig_Environment){
46 46
 			$view->addGlobal($key,$value);
47 47
 		}
48 48
 	}
Please login to merge, or discard this patch.