-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.php
91 lines (78 loc) · 2.2 KB
/
app.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
85
86
87
88
89
90
91
<?php
include dirname( __FILE__ ) . '/vendor/autoload.php';
use DirectoristAppToolkit\Helper\Traits;
use DirectoristAppToolkit\Lib;
use DirectoristAppToolkit\Controller;
final class DirectoristAppToolkit {
use Traits\Service_Registrar;
public static $instance;
/**
* The Constructor
*
* Making it private so that the class can't
* be instantiate with new keyword
*
*/
private function __construct() {
$this->register_serivces( $this->get_controllers() );
}
/**
* Get the instance of the class
*
* It insures that the class doesn't instantiate twice
* to maintain the Singleton pattern.
*
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Get the controllers
*
* @return array a list of controllers
*
*/
public static function get_controllers() {
return [
// Libraries
Lib\JWT\Init::class,
// Controllers
Controller\Notification\Init::class,
Controller\Rest_API\Init::class,
Controller\Admin_Settings\Init::class,
Controller\iFrame_Login\Init::class,
];
}
/**
* Throw error on object clone.
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @return void
* @since 1.0
* @access protected
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __('Cheatin’ huh?', 'directorist-app-toolkit'), '1.0' );
}
/**
* Disable unserializing of the class.
*
* @return void
* @since 1.0
* @access protected
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __('Cheatin’ huh?', 'directorist-app-toolkit'), '1.0' );
}
}
function DirectoristAppToolkit() {
return DirectoristAppToolkit::get_instance();
}
DirectoristAppToolkit();