Passed
Push — master ( c5e11d...bd0bd9 )
by Jean-Christophe
05:42
created

AdminScaffoldController::showSimpleMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 6
crap 2
1
<?php
2
3
namespace Ubiquity\scaffolding;
4
5
use Ajax\semantic\html\elements\HtmlButton;
6
use Ubiquity\controllers\Startup;
7
use Ubiquity\utils\http\USession;
8
9
class AdminScaffoldController extends ScaffoldController {
10
	private $msgCallback;
11
12
	public function __construct($controller) {
13
		$this->msgCallback = function ($content, $type, $title = null, $icon = "info", $timeout = NULL, $staticName = null) use ($controller) {
14
			$controller->showSimpleMessage ( $content, $type, $title, $icon, $timeout, $staticName );
15
		};
16
	}
17
18
	protected function getTemplateDir() {
19
		return Startup::getFrameworkDir () . "/admin/templates/";
20
	}
21
22
	protected function showSimpleMessage($content, $type, $title = null, $icon = "info", $timeout = NULL, $staticName = null) {
23
		return $this->msgCallback ( $content, $type, $title, $icon, $timeout, $staticName );
0 ignored issues
show
Bug introduced by
The method msgCallback() does not exist on Ubiquity\scaffolding\AdminScaffoldController. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
		return $this->/** @scrutinizer ignore-call */ msgCallback ( $content, $type, $title, $icon, $timeout, $staticName );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
24
	}
25
26
	protected function _addMessageForRouteCreation($path, $jsCallback = "") {
27
		$msgContent = "<br>Created route : <b>" . $path . "</b>";
28
		$msgContent .= "<br>You need to re-init Router cache to apply this update:";
29
		$btReinitCache = new HtmlButton ( "bt-init-cache", "(Re-)Init router cache", "orange" );
30
		$btReinitCache->addIcon ( "refresh" );
31
		$msgContent .= "&nbsp;" . $btReinitCache;
32
		$this->jquery->getOnClick ( "#bt-init-cache", $this->_getFiles ()->getAdminBaseRoute () . "/_refreshCacheControllers", "#messages", [ "attr" => "","hasLoader" => false,"dataType" => "html","jsCallback" => $jsCallback ] );
0 ignored issues
show
Bug Best Practice introduced by
The property jquery does not exist on Ubiquity\scaffolding\AdminScaffoldController. Did you maybe forget to declare it?
Loading history...
Bug introduced by
The method _getFiles() does not exist on Ubiquity\scaffolding\AdminScaffoldController. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
		$this->jquery->getOnClick ( "#bt-init-cache", $this->/** @scrutinizer ignore-call */ _getFiles ()->getAdminBaseRoute () . "/_refreshCacheControllers", "#messages", [ "attr" => "","hasLoader" => false,"dataType" => "html","jsCallback" => $jsCallback ] );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
		return $msgContent;
34
	}
35
36
	protected function storeControllerNameInSession($controller) {
37
		USession::addOrRemoveValueFromArray ( "filtered-controllers", $controller, true );
38
	}
39
40
	public static function createClass($controller, $template, $classname, $namespace, $uses, $extendsOrImplements, $classContent) {
41
		$self = new AdminScaffoldController ( $controller );
42
		return $self->_createClass ( $template, $classname, $namespace, $uses, $extendsOrImplements, $classContent );
43
	}
44
45
	public static function createMethod($controller, $access, $name, $parameters, $return, $content, $comment) {
46
		$self = new AdminScaffoldController ( $controller );
47
		return $self->_createMethod ( $access, $name, $parameters, $return, $content, $comment );
48
	}
49
}
50
51