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