-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcurrent.php
executable file
·84 lines (65 loc) · 1.95 KB
/
current.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require('library/registries/registry.php');
require('library/registries/request.php');
require('library/registries/config.php');
require('library/registries/store.php');
/*
Class:
<Current>
A container class for registries and other site-wide classes. It is not meant to be instantiated, and therefor has no non-static methods.
*/
class Current
{
/*
Method:
<Current::initialize>
Add all registries to self, _except_ those that are extra special. Can be called as many times as seen fit, but seeing as every call is to a registry, nothing new will happen the second time around.
*/
public static function initialize($path)
{
Config::setPath($path . 'config/');
self::$request = Request::instance();
self::$config = Config::instance();
self::$store = Store::instance();
}
/*
Method:
<Current::db>
Method for fetching the database instance. If no instance has yet been created, create one.
Parameters:
string $driver - The driver to use, e.g "mysql" or "directory", etc
Returns:
The global database instance.
*/
public static function db($driver)
{
if ( ! isset(self::$db[$driver]) )
{
list($server, $user, $pass, $database) = self::$config->gets('db.server', 'db.user', 'db.password', 'db.database');
$dbclass = $driver . 'DB';
self::$db[$driver] = new $dbclass($server, $user, $pass, $database);
}
return self::$db[$driver];
}
// Property: <Current::$request>
// $_POST, $_GET, $_COOKIE data
public static $request;
// Property: <Current::$db>
// Database object
public static $db = array();
// Property: <Current::$store>
// User session registry
public static $store;
// Property: <Current::$config>
// Global config object
public static $config;
// Property: <Current::$plugins>
// Current plugin object.
public static $plugins;
// Property: <Current::$log>
// A generic log
public static $log;
// Property: <Current::$user>
// A user object
public static $user;
}