1 | <?php |
||
19 | class Config { |
||
20 | |||
21 | const FEATURE_ENSURED = 1; |
||
22 | const FEATURE_NOT_AVAILABLE = 0; |
||
23 | const FEATURE_ALREADY_ENSURED = -1; |
||
24 | |||
25 | /** |
||
26 | * The initial setting values. |
||
27 | * |
||
28 | * @var Array |
||
29 | */ |
||
30 | protected $config = array( |
||
31 | 'jitm' => false, |
||
32 | 'connection' => false, |
||
33 | 'sync' => false, |
||
34 | 'tracking' => false, |
||
35 | 'tos' => false, |
||
36 | ); |
||
37 | |||
38 | /** |
||
39 | * Creates the configuration class instance. |
||
40 | */ |
||
41 | public function __construct() { |
||
49 | |||
50 | /** |
||
51 | * Require a feature to be initialized. It's up to the package consumer to actually add |
||
52 | * the package to their composer project. Declaring a requirement using this method |
||
53 | * instructs the class to initalize it. |
||
54 | * |
||
55 | * @param String $feature the feature slug. |
||
56 | */ |
||
57 | public function ensure( $feature ) { |
||
60 | |||
61 | /** |
||
62 | * Runs on plugins_loaded hook priority with priority 2. |
||
63 | * |
||
64 | * @action plugins_loaded |
||
65 | */ |
||
66 | public function on_plugins_loaded() { |
||
89 | |||
90 | /** |
||
91 | * Returns true if the required class is available and alerts the user if it's not available |
||
92 | * in case the site is in debug mode. |
||
93 | * |
||
94 | * @param String $classname a fully qualified class name. |
||
95 | * @return Boolean whether the class is available. |
||
96 | */ |
||
97 | protected function ensure_class( $classname ) { |
||
116 | |||
117 | /** |
||
118 | * Ensures a feature is enabled, sets it up if it hasn't already been set up. |
||
119 | * |
||
120 | * @param String $feature slug of the feature. |
||
121 | * @return Integer either FEATURE_ENSURED, FEATURE_ALREADY_ENSURED or FEATURE_NOT_AVAILABLE constants. |
||
122 | */ |
||
123 | protected function ensure_feature( $feature ) { |
||
144 | |||
145 | /** |
||
146 | * Dummy method to enable Terms of Service. |
||
147 | */ |
||
148 | protected function enable_tos() { |
||
151 | |||
152 | /** |
||
153 | * Enables the tracking feature. Depends on the Terms of Service package, so enables it too. |
||
154 | */ |
||
155 | protected function enable_tracking() { |
||
173 | |||
174 | /** |
||
175 | * Enables the JITM feature. |
||
176 | */ |
||
177 | protected function enable_jitm() { |
||
182 | |||
183 | /** |
||
184 | * Enables the Sync feature. |
||
185 | */ |
||
186 | protected function enable_sync() { |
||
191 | |||
192 | /** |
||
193 | * Enables the Connection feature. |
||
194 | */ |
||
195 | protected function enable_connection() { |
||
200 | |||
201 | } |
||
202 |