1 | <?php |
||
20 | class WordPoints_App { |
||
21 | |||
22 | /** |
||
23 | * The main app. |
||
24 | * |
||
25 | * @since 1.0.0 |
||
26 | * |
||
27 | * @var WordPoints_App |
||
28 | */ |
||
29 | public static $main; |
||
30 | |||
31 | /** |
||
32 | * The slug of this app. |
||
33 | * |
||
34 | * @since 1.0.0 |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $slug; |
||
39 | |||
40 | /** |
||
41 | * The full slug of this app, prefixed with the slug of the parent app. |
||
42 | * |
||
43 | * @since 1.0.0 |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $full_slug; |
||
48 | |||
49 | /** |
||
50 | * A registry for child apps. |
||
51 | * |
||
52 | * @since 1.0.0 |
||
53 | * |
||
54 | * @var WordPoints_Class_Registry_Persistent |
||
55 | */ |
||
56 | protected $sub_apps; |
||
57 | |||
58 | /** |
||
59 | * The parent of this app, if this is a sub-app. |
||
60 | * |
||
61 | * @since 1.0.0 |
||
62 | * |
||
63 | * @var WordPoints_App |
||
64 | */ |
||
65 | protected $parent; |
||
66 | |||
67 | /** |
||
68 | * Whether to skip calling an action when each registry is initialized. |
||
69 | * |
||
70 | * @since 1.0.0 |
||
71 | * |
||
72 | * @var bool |
||
73 | */ |
||
74 | protected $silent = false; |
||
75 | |||
76 | /** |
||
77 | * Keeps track of which registries have been initialized. |
||
78 | * |
||
79 | * @since 1.0.0 |
||
80 | * |
||
81 | * @var bool[] |
||
82 | */ |
||
83 | protected $did_init = array(); |
||
84 | |||
85 | /** |
||
86 | * Whether properties are allowed to be set. |
||
87 | * |
||
88 | * @since 1.0.0 |
||
89 | * |
||
90 | * @var bool |
||
91 | */ |
||
92 | protected $allow_set = false; |
||
93 | |||
94 | /** |
||
95 | * @since 1.0.0 |
||
96 | */ |
||
97 | public function __construct( $slug, $parent = null ) { |
||
114 | |||
115 | /** |
||
116 | * Get a sub app. |
||
117 | * |
||
118 | * @since 1.0.0 |
||
119 | * |
||
120 | * @param string $slug The slug of the sub-app to get. |
||
121 | * |
||
122 | * @return null|object|WordPoints_App|WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI The sub app, or null if not found. |
||
123 | */ |
||
124 | public function get_sub_app( $slug ) { |
||
155 | |||
156 | /** |
||
157 | * Get the sub apps registry. |
||
158 | * |
||
159 | * @since 1.0.0 |
||
160 | * |
||
161 | * @return WordPoints_Class_Registry_Persistent The sub apps registry. |
||
162 | */ |
||
163 | public function sub_apps() { |
||
166 | |||
167 | /** |
||
168 | * Check whether to call the init action for a registry sub-app. |
||
169 | * |
||
170 | * @since 1.0.0 |
||
171 | * |
||
172 | * @param object $registry The sub-app object. |
||
173 | * |
||
174 | * @return bool Whether to call the init action or not. |
||
175 | */ |
||
176 | protected function should_do_registry_init( $registry ) { |
||
182 | |||
183 | /** |
||
184 | * Initialize this app. |
||
185 | * |
||
186 | * @since 1.0.0 |
||
187 | */ |
||
188 | protected function init() { |
||
202 | } |
||
203 | |||
205 |