Passed
Push — master ( 9673ec...b85c5f )
by Jean-Christophe
02:36
created

JsUtils::renderView()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 3
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Ajax\php\ubiquity;
4
5
use Ubiquity\controllers\Startup;
0 ignored issues
show
Bug introduced by
The type Ubiquity\controllers\Startup was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Ubiquity\utils\http\URequest;
0 ignored issues
show
Bug introduced by
The type Ubiquity\utils\http\URequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class JsUtils extends \Ajax\JsUtils{
9
10
	public function getUrl($url){
11
		return URequest::getUrl($url);
12
	}
13
14
	public function addViewElement($identifier,$content,&$view){
15
		$controls=$view->getVar("q");
16
		if (isset($controls) === false) {
17
			$controls=array ();
18
		}
19
		$controls[$identifier]=$content;
20
		$view->setVar("q", $controls);
21
	}
22
23
	public function createScriptVariable(&$view,$view_var, $output){
24
		$view->setVar($view_var,$output);
25
	}
26
27
	public function forward($initialController,$controller,$action,$params=array()){
28
		return $initialController->forward($controller,$action,$params,true,true,true);
29
	}
30
31
	public function renderContent($initialControllerInstance,$viewName, $params=NULL) {
32
		return $initialControllerInstance->loadView($viewName,$params,true);
33
	}
34
35
	public function fromDispatcher($dispatcher){
36
		return Startup::$urlParts;
37
	}
38
	
39
	/**
40
	 * Performs jQuery compilation and displays a view
41
	 * @param string $viewName
42
	 * @param mixed $parameters Variable or associative array to pass to the view <br> If a variable is passed, it will have the name <b> $ data </ b> in the view, <br>
43
	 * If an associative array is passed, the view retrieves variables from the table's key names
44
	 * @param boolean $asString If true, the view is not displayed but returned as a string (usable in a variable)
45
	 */
46
	public function renderView($viewName,$parameters=[],$asString=false){
47
		if(isset($this->injected)){
48
			$view=$this->injected->getView();
49
			$this->compile($view);
50
			if (isset($parameters))
51
				$this->view->setVars($parameters);
0 ignored issues
show
Bug Best Practice introduced by
The property view does not exist on Ajax\php\ubiquity\JsUtils. Did you maybe forget to declare it?
Loading history...
52
			return $this->view->render($viewName, $asString);
53
		}
54
		throw new \Exception(get_class()." instance is not properly instancied : you omitted the second parameter \$controller!");
55
	}
56
}
57