@@ -25,212 +25,212 @@ |
||
25 | 25 | class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var EE_Request $request |
|
30 | - */ |
|
31 | - protected $request; |
|
28 | + /** |
|
29 | + * @var EE_Request $request |
|
30 | + */ |
|
31 | + protected $request; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var EE_Response $response |
|
35 | - */ |
|
36 | - protected $response; |
|
33 | + /** |
|
34 | + * @var EE_Response $response |
|
35 | + */ |
|
36 | + protected $response; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var EE_Dependency_Map $dependency_map |
|
40 | - */ |
|
41 | - protected $dependency_map; |
|
38 | + /** |
|
39 | + * @var EE_Dependency_Map $dependency_map |
|
40 | + */ |
|
41 | + protected $dependency_map; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var EE_Registry $registry |
|
45 | - */ |
|
46 | - protected $registry; |
|
43 | + /** |
|
44 | + * @var EE_Registry $registry |
|
45 | + */ |
|
46 | + protected $registry; |
|
47 | 47 | |
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * EE_Load_Espresso_Core constructor |
|
52 | - */ |
|
50 | + /** |
|
51 | + * EE_Load_Espresso_Core constructor |
|
52 | + */ |
|
53 | 53 | public function __construct() { |
54 | - // deprecated functions |
|
55 | - espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
56 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * handle |
|
63 | - * sets hooks for running rest of system |
|
64 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
65 | - * starting EE Addons from any other point may lead to problems |
|
66 | - * |
|
67 | - * @param EE_Request $request |
|
68 | - * @param EE_Response $response |
|
69 | - * @return EE_Response |
|
70 | - * @throws EE_Error |
|
71 | - * @throws InvalidDataTypeException |
|
72 | - * @throws InvalidInterfaceException |
|
73 | - * @throws InvalidArgumentException |
|
74 | - */ |
|
75 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
76 | - { |
|
77 | - $this->request = $request; |
|
78 | - $this->response = $response; |
|
79 | - // info about how to load classes required by other classes |
|
80 | - $this->dependency_map = $this->_load_dependency_map(); |
|
81 | - // central repository for classes |
|
82 | - $this->registry = $this->_load_registry(); |
|
83 | - do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
84 | - $loader = LoaderFactory::getLoader($this->registry); |
|
85 | - $this->dependency_map->setLoader($loader); |
|
86 | - // instantiate core Domain class |
|
87 | - DomainFactory::create( |
|
88 | - 'EventEspresso\core\domain\Domain', |
|
89 | - array( |
|
90 | - EVENT_ESPRESSO_MAIN_FILE, |
|
91 | - espresso_version() |
|
92 | - ) |
|
93 | - ); |
|
94 | - // build DI container |
|
95 | - // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
96 | - // $OpenCoffeeShop->addRecipes(); |
|
97 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
98 | - // workarounds for PHP < 5.3 |
|
99 | - $this->_load_class_tools(); |
|
100 | - // deprecated functions |
|
101 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
102 | - // WP cron jobs |
|
103 | - $loader->getShared('EE_Cron_Tasks'); |
|
104 | - $loader->getShared('EE_Request_Handler'); |
|
105 | - $loader->getShared('EE_System'); |
|
106 | - return $this->response; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @return EE_Request |
|
113 | - */ |
|
114 | - public function request() |
|
115 | - { |
|
116 | - return $this->request; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @return EE_Response |
|
123 | - */ |
|
124 | - public function response() |
|
125 | - { |
|
126 | - return $this->response; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return EE_Dependency_Map |
|
133 | - * @throws EE_Error |
|
134 | - */ |
|
135 | - public function dependency_map() |
|
136 | - { |
|
137 | - if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
138 | - throw new EE_Error( |
|
139 | - sprintf( |
|
140 | - __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
141 | - print_r($this->dependency_map, true) |
|
142 | - ) |
|
143 | - ); |
|
144 | - } |
|
145 | - return $this->dependency_map; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @return EE_Registry |
|
152 | - * @throws EE_Error |
|
153 | - */ |
|
154 | - public function registry() |
|
155 | - { |
|
156 | - if (! $this->registry instanceof EE_Registry) { |
|
157 | - throw new EE_Error( |
|
158 | - sprintf( |
|
159 | - __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
160 | - print_r($this->registry, true) |
|
161 | - ) |
|
162 | - ); |
|
163 | - } |
|
164 | - return $this->registry; |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @return EE_Dependency_Map |
|
171 | - */ |
|
172 | - private function _load_dependency_map() |
|
173 | - { |
|
174 | - if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
175 | - EE_Error::add_error( |
|
176 | - __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
177 | - __FILE__, __FUNCTION__, __LINE__ |
|
178 | - ); |
|
179 | - wp_die(EE_Error::get_notices()); |
|
180 | - } |
|
181 | - require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
182 | - return EE_Dependency_Map::instance($this->request, $this->response); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * @return EE_Registry |
|
189 | - */ |
|
190 | - private function _load_registry() |
|
191 | - { |
|
192 | - if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
193 | - EE_Error::add_error( |
|
194 | - __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
195 | - __FILE__, __FUNCTION__, __LINE__ |
|
196 | - ); |
|
197 | - wp_die(EE_Error::get_notices()); |
|
198 | - } |
|
199 | - require_once(EE_CORE . 'EE_Registry.core.php'); |
|
200 | - return EE_Registry::instance($this->dependency_map); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * @return void |
|
207 | - */ |
|
208 | - private function _load_class_tools() |
|
209 | - { |
|
210 | - if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
211 | - EE_Error::add_error( |
|
212 | - __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
213 | - __FILE__, __FUNCTION__, __LINE__ |
|
214 | - ); |
|
215 | - } |
|
216 | - require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * called after the request stack has been fully processed |
|
223 | - * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
224 | - * |
|
225 | - * @param EE_Request $request |
|
226 | - * @param EE_Response $response |
|
227 | - */ |
|
228 | - public function handle_response(EE_Request $request, EE_Response $response) |
|
229 | - { |
|
230 | - if ($response->plugin_deactivated()) { |
|
231 | - espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
232 | - } |
|
233 | - } |
|
54 | + // deprecated functions |
|
55 | + espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
56 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * handle |
|
63 | + * sets hooks for running rest of system |
|
64 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
65 | + * starting EE Addons from any other point may lead to problems |
|
66 | + * |
|
67 | + * @param EE_Request $request |
|
68 | + * @param EE_Response $response |
|
69 | + * @return EE_Response |
|
70 | + * @throws EE_Error |
|
71 | + * @throws InvalidDataTypeException |
|
72 | + * @throws InvalidInterfaceException |
|
73 | + * @throws InvalidArgumentException |
|
74 | + */ |
|
75 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
76 | + { |
|
77 | + $this->request = $request; |
|
78 | + $this->response = $response; |
|
79 | + // info about how to load classes required by other classes |
|
80 | + $this->dependency_map = $this->_load_dependency_map(); |
|
81 | + // central repository for classes |
|
82 | + $this->registry = $this->_load_registry(); |
|
83 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
84 | + $loader = LoaderFactory::getLoader($this->registry); |
|
85 | + $this->dependency_map->setLoader($loader); |
|
86 | + // instantiate core Domain class |
|
87 | + DomainFactory::create( |
|
88 | + 'EventEspresso\core\domain\Domain', |
|
89 | + array( |
|
90 | + EVENT_ESPRESSO_MAIN_FILE, |
|
91 | + espresso_version() |
|
92 | + ) |
|
93 | + ); |
|
94 | + // build DI container |
|
95 | + // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
96 | + // $OpenCoffeeShop->addRecipes(); |
|
97 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
98 | + // workarounds for PHP < 5.3 |
|
99 | + $this->_load_class_tools(); |
|
100 | + // deprecated functions |
|
101 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
102 | + // WP cron jobs |
|
103 | + $loader->getShared('EE_Cron_Tasks'); |
|
104 | + $loader->getShared('EE_Request_Handler'); |
|
105 | + $loader->getShared('EE_System'); |
|
106 | + return $this->response; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @return EE_Request |
|
113 | + */ |
|
114 | + public function request() |
|
115 | + { |
|
116 | + return $this->request; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @return EE_Response |
|
123 | + */ |
|
124 | + public function response() |
|
125 | + { |
|
126 | + return $this->response; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return EE_Dependency_Map |
|
133 | + * @throws EE_Error |
|
134 | + */ |
|
135 | + public function dependency_map() |
|
136 | + { |
|
137 | + if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
138 | + throw new EE_Error( |
|
139 | + sprintf( |
|
140 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
141 | + print_r($this->dependency_map, true) |
|
142 | + ) |
|
143 | + ); |
|
144 | + } |
|
145 | + return $this->dependency_map; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @return EE_Registry |
|
152 | + * @throws EE_Error |
|
153 | + */ |
|
154 | + public function registry() |
|
155 | + { |
|
156 | + if (! $this->registry instanceof EE_Registry) { |
|
157 | + throw new EE_Error( |
|
158 | + sprintf( |
|
159 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
160 | + print_r($this->registry, true) |
|
161 | + ) |
|
162 | + ); |
|
163 | + } |
|
164 | + return $this->registry; |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @return EE_Dependency_Map |
|
171 | + */ |
|
172 | + private function _load_dependency_map() |
|
173 | + { |
|
174 | + if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
175 | + EE_Error::add_error( |
|
176 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
177 | + __FILE__, __FUNCTION__, __LINE__ |
|
178 | + ); |
|
179 | + wp_die(EE_Error::get_notices()); |
|
180 | + } |
|
181 | + require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
182 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * @return EE_Registry |
|
189 | + */ |
|
190 | + private function _load_registry() |
|
191 | + { |
|
192 | + if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
193 | + EE_Error::add_error( |
|
194 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
195 | + __FILE__, __FUNCTION__, __LINE__ |
|
196 | + ); |
|
197 | + wp_die(EE_Error::get_notices()); |
|
198 | + } |
|
199 | + require_once(EE_CORE . 'EE_Registry.core.php'); |
|
200 | + return EE_Registry::instance($this->dependency_map); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * @return void |
|
207 | + */ |
|
208 | + private function _load_class_tools() |
|
209 | + { |
|
210 | + if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
211 | + EE_Error::add_error( |
|
212 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
213 | + __FILE__, __FUNCTION__, __LINE__ |
|
214 | + ); |
|
215 | + } |
|
216 | + require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * called after the request stack has been fully processed |
|
223 | + * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
224 | + * |
|
225 | + * @param EE_Request $request |
|
226 | + * @param EE_Response $response |
|
227 | + */ |
|
228 | + public function handle_response(EE_Request $request, EE_Response $response) |
|
229 | + { |
|
230 | + if ($response->plugin_deactivated()) { |
|
231 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
232 | + } |
|
233 | + } |
|
234 | 234 | |
235 | 235 | |
236 | 236 |
@@ -19,157 +19,157 @@ |
||
19 | 19 | abstract class DomainBase implements DomainInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Equivalent to `__FILE__` for main plugin file. |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - private $plugin_file; |
|
28 | - |
|
29 | - /** |
|
30 | - * String indicating version for plugin |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - private $version; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string $plugin_basename |
|
38 | - */ |
|
39 | - private $plugin_basename; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string $plugin_path |
|
43 | - */ |
|
44 | - private $plugin_path; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string $plugin_url |
|
48 | - */ |
|
49 | - private $plugin_url; |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Initializes internal properties. |
|
55 | - * |
|
56 | - * @param string $plugin_file |
|
57 | - * @param string $version |
|
58 | - * @throws InvalidArgumentException |
|
59 | - */ |
|
60 | - public function __construct($plugin_file, $version) |
|
61 | - { |
|
62 | - $this->setPluginFile($plugin_file); |
|
63 | - $this->setVersion($version); |
|
64 | - $this->plugin_basename = plugin_basename($plugin_file); |
|
65 | - $this->plugin_path = plugin_dir_path($plugin_file); |
|
66 | - $this->plugin_url = plugin_dir_url($plugin_file); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @param string $plugin_file |
|
72 | - * @throws InvalidArgumentException |
|
73 | - */ |
|
74 | - private function setPluginFile($plugin_file) |
|
75 | - { |
|
76 | - if(empty($plugin_file) || ! is_string($plugin_file)){ |
|
77 | - throw new InvalidArgumentException( |
|
78 | - esc_html__( |
|
79 | - 'You need to supply a path to the addon plugin file in order to generate a Domain class', |
|
80 | - 'event_espresso' |
|
81 | - ) |
|
82 | - ); |
|
83 | - } |
|
84 | - if(! is_readable($plugin_file)){ |
|
85 | - throw new InvalidArgumentException( |
|
86 | - esc_html__( |
|
87 | - 'You need to supply a valid path to the addon plugin file in order to generate a Domain class', |
|
88 | - 'event_espresso' |
|
89 | - ) |
|
90 | - ); |
|
91 | - } |
|
92 | - $this->plugin_file = $plugin_file; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $version |
|
98 | - * @throws InvalidArgumentException |
|
99 | - */ |
|
100 | - private function setVersion($version) |
|
101 | - { |
|
102 | - if (empty($version) || ! is_string($version)) { |
|
103 | - throw new InvalidArgumentException( |
|
104 | - esc_html__( |
|
105 | - 'You need to supply a version string in order to generate a Domain class', |
|
106 | - 'event_espresso' |
|
107 | - ) |
|
108 | - ); |
|
109 | - } |
|
110 | - if (strpos($version, '.') === false) { |
|
111 | - throw new InvalidArgumentException( |
|
112 | - esc_html__( |
|
113 | - 'You need to supply a valid version string in order to generate a Domain class', |
|
114 | - 'event_espresso' |
|
115 | - ) |
|
116 | - ); |
|
117 | - } |
|
118 | - $this->version = $version; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return string |
|
124 | - * @throws DomainException |
|
125 | - */ |
|
126 | - public function pluginFile() |
|
127 | - { |
|
128 | - return $this->plugin_file; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @return string |
|
135 | - * @throws DomainException |
|
136 | - */ |
|
137 | - public function pluginBasename() |
|
138 | - { |
|
139 | - return $this->plugin_basename; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function pluginPath() |
|
148 | - { |
|
149 | - return $this->plugin_path; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @return string |
|
156 | - * @throws DomainException |
|
157 | - */ |
|
158 | - public function pluginUrl() |
|
159 | - { |
|
160 | - return $this->plugin_url; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @return string |
|
167 | - * @throws DomainException |
|
168 | - */ |
|
169 | - public function version() |
|
170 | - { |
|
171 | - return $this->version; |
|
172 | - } |
|
22 | + /** |
|
23 | + * Equivalent to `__FILE__` for main plugin file. |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + private $plugin_file; |
|
28 | + |
|
29 | + /** |
|
30 | + * String indicating version for plugin |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + private $version; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string $plugin_basename |
|
38 | + */ |
|
39 | + private $plugin_basename; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string $plugin_path |
|
43 | + */ |
|
44 | + private $plugin_path; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string $plugin_url |
|
48 | + */ |
|
49 | + private $plugin_url; |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Initializes internal properties. |
|
55 | + * |
|
56 | + * @param string $plugin_file |
|
57 | + * @param string $version |
|
58 | + * @throws InvalidArgumentException |
|
59 | + */ |
|
60 | + public function __construct($plugin_file, $version) |
|
61 | + { |
|
62 | + $this->setPluginFile($plugin_file); |
|
63 | + $this->setVersion($version); |
|
64 | + $this->plugin_basename = plugin_basename($plugin_file); |
|
65 | + $this->plugin_path = plugin_dir_path($plugin_file); |
|
66 | + $this->plugin_url = plugin_dir_url($plugin_file); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @param string $plugin_file |
|
72 | + * @throws InvalidArgumentException |
|
73 | + */ |
|
74 | + private function setPluginFile($plugin_file) |
|
75 | + { |
|
76 | + if(empty($plugin_file) || ! is_string($plugin_file)){ |
|
77 | + throw new InvalidArgumentException( |
|
78 | + esc_html__( |
|
79 | + 'You need to supply a path to the addon plugin file in order to generate a Domain class', |
|
80 | + 'event_espresso' |
|
81 | + ) |
|
82 | + ); |
|
83 | + } |
|
84 | + if(! is_readable($plugin_file)){ |
|
85 | + throw new InvalidArgumentException( |
|
86 | + esc_html__( |
|
87 | + 'You need to supply a valid path to the addon plugin file in order to generate a Domain class', |
|
88 | + 'event_espresso' |
|
89 | + ) |
|
90 | + ); |
|
91 | + } |
|
92 | + $this->plugin_file = $plugin_file; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $version |
|
98 | + * @throws InvalidArgumentException |
|
99 | + */ |
|
100 | + private function setVersion($version) |
|
101 | + { |
|
102 | + if (empty($version) || ! is_string($version)) { |
|
103 | + throw new InvalidArgumentException( |
|
104 | + esc_html__( |
|
105 | + 'You need to supply a version string in order to generate a Domain class', |
|
106 | + 'event_espresso' |
|
107 | + ) |
|
108 | + ); |
|
109 | + } |
|
110 | + if (strpos($version, '.') === false) { |
|
111 | + throw new InvalidArgumentException( |
|
112 | + esc_html__( |
|
113 | + 'You need to supply a valid version string in order to generate a Domain class', |
|
114 | + 'event_espresso' |
|
115 | + ) |
|
116 | + ); |
|
117 | + } |
|
118 | + $this->version = $version; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return string |
|
124 | + * @throws DomainException |
|
125 | + */ |
|
126 | + public function pluginFile() |
|
127 | + { |
|
128 | + return $this->plugin_file; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @return string |
|
135 | + * @throws DomainException |
|
136 | + */ |
|
137 | + public function pluginBasename() |
|
138 | + { |
|
139 | + return $this->plugin_basename; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function pluginPath() |
|
148 | + { |
|
149 | + return $this->plugin_path; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @return string |
|
156 | + * @throws DomainException |
|
157 | + */ |
|
158 | + public function pluginUrl() |
|
159 | + { |
|
160 | + return $this->plugin_url; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @return string |
|
167 | + * @throws DomainException |
|
168 | + */ |
|
169 | + public function version() |
|
170 | + { |
|
171 | + return $this->version; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | 175 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function setPluginFile($plugin_file) |
75 | 75 | { |
76 | - if(empty($plugin_file) || ! is_string($plugin_file)){ |
|
76 | + if (empty($plugin_file) || ! is_string($plugin_file)) { |
|
77 | 77 | throw new InvalidArgumentException( |
78 | 78 | esc_html__( |
79 | 79 | 'You need to supply a path to the addon plugin file in order to generate a Domain class', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ) |
82 | 82 | ); |
83 | 83 | } |
84 | - if(! is_readable($plugin_file)){ |
|
84 | + if ( ! is_readable($plugin_file)) { |
|
85 | 85 | throw new InvalidArgumentException( |
86 | 86 | esc_html__( |
87 | 87 | 'You need to supply a valid path to the addon plugin file in order to generate a Domain class', |
@@ -22,32 +22,32 @@ |
||
22 | 22 | class DomainFactory |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @param string $domain_fcqn [required] Fully Qualified Class Name for the Domain class |
|
27 | - * @param array $arguments [required] array of arguments to be passed to the Domain class constructor. |
|
28 | - * must include the following two elements as a minimum: |
|
29 | - * array( |
|
30 | - * $plugin_file, // full server path to the addon main file (__FILE__) |
|
31 | - * $version, // standard version string like #.#.# |
|
32 | - * ) |
|
33 | - * @return mixed |
|
34 | - * @throws InvalidArgumentException |
|
35 | - * @throws InvalidDataTypeException |
|
36 | - * @throws InvalidInterfaceException |
|
37 | - */ |
|
38 | - public static function create($domain_fcqn = '', array $arguments) |
|
39 | - { |
|
40 | - if(!isset($arguments[0], $arguments[1])) { |
|
41 | - throw new InvalidArgumentException( |
|
42 | - esc_html__( |
|
43 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
44 | - 'event_espresso' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
48 | - $loader = LoaderFactory::getLoader(); |
|
49 | - return $loader->getShared($domain_fcqn, $arguments); |
|
50 | - } |
|
25 | + /** |
|
26 | + * @param string $domain_fcqn [required] Fully Qualified Class Name for the Domain class |
|
27 | + * @param array $arguments [required] array of arguments to be passed to the Domain class constructor. |
|
28 | + * must include the following two elements as a minimum: |
|
29 | + * array( |
|
30 | + * $plugin_file, // full server path to the addon main file (__FILE__) |
|
31 | + * $version, // standard version string like #.#.# |
|
32 | + * ) |
|
33 | + * @return mixed |
|
34 | + * @throws InvalidArgumentException |
|
35 | + * @throws InvalidDataTypeException |
|
36 | + * @throws InvalidInterfaceException |
|
37 | + */ |
|
38 | + public static function create($domain_fcqn = '', array $arguments) |
|
39 | + { |
|
40 | + if(!isset($arguments[0], $arguments[1])) { |
|
41 | + throw new InvalidArgumentException( |
|
42 | + esc_html__( |
|
43 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
44 | + 'event_espresso' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | + $loader = LoaderFactory::getLoader(); |
|
49 | + return $loader->getShared($domain_fcqn, $arguments); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | // Location: DomainFactory.php |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public static function create($domain_fcqn = '', array $arguments) |
39 | 39 | { |
40 | - if(!isset($arguments[0], $arguments[1])) { |
|
40 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
41 | 41 | throw new InvalidArgumentException( |
42 | 42 | esc_html__( |
43 | 43 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -15,36 +15,36 @@ |
||
15 | 15 | interface DomainInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return string |
|
20 | - * @throws DomainException |
|
21 | - */ |
|
22 | - public function pluginFile(); |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + * @throws DomainException |
|
21 | + */ |
|
22 | + public function pluginFile(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @return string |
|
27 | - * @throws DomainException |
|
28 | - */ |
|
29 | - public function pluginBasename(); |
|
25 | + /** |
|
26 | + * @return string |
|
27 | + * @throws DomainException |
|
28 | + */ |
|
29 | + public function pluginBasename(); |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function pluginPath(); |
|
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function pluginPath(); |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return string |
|
40 | - * @throws DomainException |
|
41 | - */ |
|
42 | - public function pluginUrl(); |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + * @throws DomainException |
|
41 | + */ |
|
42 | + public function pluginUrl(); |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @return string |
|
47 | - * @throws DomainException |
|
48 | - */ |
|
49 | - public function version(); |
|
45 | + /** |
|
46 | + * @return string |
|
47 | + * @throws DomainException |
|
48 | + */ |
|
49 | + public function version(); |
|
50 | 50 | } |