Test Failed
Push — master ( 545d2f...b75c4f )
by Jean-Christophe
10:08
created

Framework::getNormalizer()   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 1
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * This class gives access to useful methods or objects of the framework.
5
 * Ubiquity\core
6
 * This class is part of Ubiquity
7
 * @author jcheron <[email protected]>
8
 * @version 1.0.3
9
 *
10
 */
11
namespace Ubiquity\core;
12
13
use Ubiquity\controllers\Startup;
14
use Ubiquity\controllers\Router;
15
use Ubiquity\utils\http\URequest;
16
use Ubiquity\utils\http\USession;
17
use Ubiquity\utils\http\UCookie;
18
use Ubiquity\orm\OrmUtils;
19
use Ubiquity\translation\TranslatorManager;
20
use Ubiquity\contents\normalizers\NormalizersManager;
21
use Ubiquity\assets\AssetsManager;
22
use Ubiquity\controllers\Controller;
23
24
class Framework {
25
	public const version = '2.0.11+';
26 2
27 2
	public static function getVersion() {
28
		return self::version;
29
	}
30 2
31 2
	public static function getController() {
32
		return Startup::getController ();
33
	}
34 2
35 2
	public static function getAction() {
36
		return Startup::getAction ();
37
	}
38 2
39 2
	public static function getUrl() {
40
		return \implode ( "/", Startup::$urlParts );
41
	}
42
43
	public static function getRouter() {
44
		return new Router ();
45
	}
46
47
	public static function getORM() {
48
		return new OrmUtils ();
49
	}
50
51
	public static function getRequest() {
52
		return new URequest ();
53
	}
54
55
	public static function getSession() {
56
		return new USession ();
57
	}
58
59
	public static function getCookies() {
60
		return new UCookie ();
61
	}
62
63
	public static function getTranslator() {
64
		return new TranslatorManager ();
65
	}
66
67
	public static function getNormalizer() {
68
		return new NormalizersManager ();
69
	}
70 2
71 2
	public static function hasAdmin() {
72
		return \class_exists ( "controllers\Admin" );
73
	}
74
75
	public static function getAssets() {
76
		return new AssetsManager ();
77
	}
78
79
	/**
80
	 * Returns an instance of JsUtils initialized with Semantic (for di injection)
81
	 *
82
	 * @param Controller $controller
83
	 * @param array $options
84
	 * @return \Ajax\php\ubiquity\JsUtils
85
	 */
86
	public static function diSemantic($controller, $options = ["defer"=>true,"gc"=>true]) {
87
		$jquery = new \Ajax\php\ubiquity\JsUtils ( $options, $controller );
88
		$jquery->semantic ( new \Ajax\Semantic () );
89
		$jquery->setAjaxLoader ( "<div class=\"ui active centered inline text loader\">Loading</div>" );
90
		return $jquery;
91
	}
92
93
	/**
94
	 * Returns an instance of JsUtils initialized with Bootstrap (for di injection)
95
	 *
96
	 * @param Controller $controller
97
	 * @param array $options
98
	 * @return \Ajax\php\ubiquity\JsUtils
99
	 */
100
	public static function diBootstrap($controller, $options = ["defer"=>true,"gc"=>true]) {
101
		$jquery = new \Ajax\php\ubiquity\JsUtils ( $options, $controller );
102
		$jquery->bootstrap ( new \Ajax\Bootstrap () );
103
		$jquery->setAjaxLoader ( "<div class=\"ui active centered inline text loader\">Loading</div>" );
104
		return $jquery;
105
	}
106
}
107
108