Passed
Push — master ( 706687...68702d )
by Jean-Christophe
07:14
created

Framework::getSession()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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.1.0';
26
27 4
	public static function getVersion() {
28 4
		return self::version;
29
	}
30
31 4
	public static function getController() {
32 4
		return Startup::getController ();
33
	}
34
35 3
	public static function getAction() {
36 3
		return Startup::getAction ();
37
	}
38
39 3
	public static function getUrl() {
40 3
		return \implode ( "/", Startup::$urlParts );
41
	}
42
43 1
	public static function getRouter() {
44 1
		return new Router ();
45
	}
46
47 1
	public static function getORM() {
48 1
		return new OrmUtils ();
49
	}
50
51 1
	public static function getRequest() {
52 1
		return new URequest ();
53
	}
54
55 1
	public static function getSession() {
56 1
		return new USession ();
57
	}
58
59 1
	public static function getCookies() {
60 1
		return new UCookie ();
61
	}
62
63 1
	public static function getTranslator() {
64 1
		return new TranslatorManager ();
65
	}
66
67 1
	public static function getNormalizer() {
68 1
		return new NormalizersManager ();
69
	}
70
71 4
	public static function hasAdmin() {
72 4
		return \class_exists ( "controllers\Admin" );
73
	}
74
75 1
	public static function getAssets() {
76 1
		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