@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function instance() { |
161 | 161 | // check if class object is instantiated |
162 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
162 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
163 | 163 | self::$_instance = new self(); |
164 | 164 | } |
165 | 165 | return self::$_instance; |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | $this->_auto_resolve_dependencies = apply_filters( |
189 | 189 | 'FHEE__EE_Registry____construct___auto_resolve_dependencies', |
190 | 190 | array( |
191 | - 'EE_Session' => array( 'EE_Encryption' ), |
|
192 | - 'EE_Cart' => array( null, 'EE_Session' ), |
|
193 | - 'EE_Front_Controller' => array( 'EE_Registry', 'EE_Request_Handler', 'EE_Module_Request_Router' ), |
|
191 | + 'EE_Session' => array('EE_Encryption'), |
|
192 | + 'EE_Cart' => array(null, 'EE_Session'), |
|
193 | + 'EE_Front_Controller' => array('EE_Registry', 'EE_Request_Handler', 'EE_Module_Request_Router'), |
|
194 | 194 | ) |
195 | 195 | ); |
196 | 196 | // class library |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | $this->modules = new StdClass(); |
200 | 200 | $this->shortcodes = new StdClass(); |
201 | 201 | $this->widgets = new StdClass(); |
202 | - $this->load_core( 'Base', array(), true ); |
|
203 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
202 | + $this->load_core('Base', array(), true); |
|
203 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function init() { |
215 | 215 | // Get current page protocol |
216 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
216 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
217 | 217 | // Output admin-ajax.php URL with same protocol as current page |
218 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
219 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
218 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
219 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | * @return string |
228 | 228 | */ |
229 | 229 | public static function localize_i18n_js_strings() { |
230 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
231 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
232 | - if ( is_scalar( $value ) ) { |
|
233 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
230 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
231 | + foreach ($i18n_js_strings as $key => $value) { |
|
232 | + if (is_scalar($value)) { |
|
233 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
237 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -242,15 +242,15 @@ discard block |
||
242 | 242 | /** |
243 | 243 | * @param mixed string | EED_Module $module |
244 | 244 | */ |
245 | - public function add_module( $module ) { |
|
246 | - if ( $module instanceof EED_Module ) { |
|
247 | - $module_class = get_class( $module ); |
|
245 | + public function add_module($module) { |
|
246 | + if ($module instanceof EED_Module) { |
|
247 | + $module_class = get_class($module); |
|
248 | 248 | $this->modules->{$module_class} = $module; |
249 | 249 | } else { |
250 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
251 | - $this->load_core( 'Module_Request_Router' ); |
|
250 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
251 | + $this->load_core('Module_Request_Router'); |
|
252 | 252 | } |
253 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
253 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | * @param string $module_name |
261 | 261 | * @return mixed EED_Module | NULL |
262 | 262 | */ |
263 | - public function get_module( $module_name = '' ) { |
|
264 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
263 | + public function get_module($module_name = '') { |
|
264 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * @param bool $resolve_dependencies |
277 | 277 | * @return mixed |
278 | 278 | */ |
279 | - public function load_core( $class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false ) { |
|
279 | + public function load_core($class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false) { |
|
280 | 280 | $core_paths = apply_filters( |
281 | 281 | 'FHEE__EE_Registry__load_core__core_paths', |
282 | 282 | array( |
283 | 283 | EE_CORE, |
284 | 284 | EE_ADMIN, |
285 | 285 | EE_CPTS, |
286 | - EE_CORE . 'data_migration_scripts' . DS |
|
286 | + EE_CORE.'data_migration_scripts'.DS |
|
287 | 287 | ) |
288 | 288 | ); |
289 | 289 | // retrieve instantiated class |
290 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies ); |
|
290 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | * @param bool $load_only |
302 | 302 | * @return mixed |
303 | 303 | */ |
304 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
304 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
305 | 305 | $service_paths = apply_filters( |
306 | 306 | 'FHEE__EE_Registry__load_service__service_paths', |
307 | 307 | array( |
308 | - EE_CORE . 'services' . DS, |
|
308 | + EE_CORE.'services'.DS, |
|
309 | 309 | ) |
310 | 310 | ); |
311 | 311 | // retrieve instantiated class |
312 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true ); |
|
312 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | * @param mixed $arguments |
323 | 323 | * @return EE_Data_Migration_Script_Base |
324 | 324 | */ |
325 | - public function load_dms( $class_name, $arguments = array() ) { |
|
325 | + public function load_dms($class_name, $arguments = array()) { |
|
326 | 326 | // retrieve instantiated class |
327 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
327 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
340 | 340 | * @return EE_Base_Class |
341 | 341 | */ |
342 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
343 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
342 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
343 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
344 | 344 | EE_CORE, |
345 | 345 | EE_CLASSES, |
346 | 346 | EE_BUSINESS |
347 | - ) ); |
|
347 | + )); |
|
348 | 348 | // retrieve instantiated class |
349 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
349 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | * @param bool $load_only |
360 | 360 | * @return EEH_Base |
361 | 361 | */ |
362 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
363 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
362 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
363 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
364 | 364 | // retrieve instantiated class |
365 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
365 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | |
@@ -376,16 +376,16 @@ discard block |
||
376 | 376 | * @param bool $load_only |
377 | 377 | * @return mixed |
378 | 378 | */ |
379 | - public function load_lib( $class_name, $arguments = array(), $load_only = false ) { |
|
379 | + public function load_lib($class_name, $arguments = array(), $load_only = false) { |
|
380 | 380 | $paths = array( |
381 | 381 | EE_LIBRARIES, |
382 | - EE_LIBRARIES . 'messages' . DS, |
|
383 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
384 | - EE_LIBRARIES . 'qtips' . DS, |
|
385 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
382 | + EE_LIBRARIES.'messages'.DS, |
|
383 | + EE_LIBRARIES.'shortcodes'.DS, |
|
384 | + EE_LIBRARIES.'qtips'.DS, |
|
385 | + EE_LIBRARIES.'payment_methods'.DS, |
|
386 | 386 | ); |
387 | 387 | // retrieve instantiated class |
388 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only ); |
|
388 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -398,13 +398,13 @@ discard block |
||
398 | 398 | * @param bool $load_only |
399 | 399 | * @return EEM_Base |
400 | 400 | */ |
401 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
402 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
401 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
402 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
403 | 403 | EE_MODELS, |
404 | 404 | EE_CORE |
405 | - ) ); |
|
405 | + )); |
|
406 | 406 | // retrieve instantiated class |
407 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
407 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -417,15 +417,15 @@ discard block |
||
417 | 417 | * @param bool $load_only |
418 | 418 | * @return mixed |
419 | 419 | */ |
420 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
420 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
421 | 421 | $paths = array( |
422 | - EE_MODELS . 'fields' . DS, |
|
423 | - EE_MODELS . 'helpers' . DS, |
|
424 | - EE_MODELS . 'relations' . DS, |
|
425 | - EE_MODELS . 'strategies' . DS |
|
422 | + EE_MODELS.'fields'.DS, |
|
423 | + EE_MODELS.'helpers'.DS, |
|
424 | + EE_MODELS.'relations'.DS, |
|
425 | + EE_MODELS.'strategies'.DS |
|
426 | 426 | ); |
427 | 427 | // retrieve instantiated class |
428 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
428 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
436 | 436 | * @return boolean |
437 | 437 | */ |
438 | - public function is_model_name( $model_name ) { |
|
439 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
438 | + public function is_model_name($model_name) { |
|
439 | + return isset($this->models[$model_name]) ? true : false; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | * @param bool $load_only |
452 | 452 | * @return mixed |
453 | 453 | */ |
454 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
454 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
455 | 455 | // retrieve instantiated class |
456 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
456 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
@@ -468,9 +468,9 @@ discard block |
||
468 | 468 | * @param bool $load_only |
469 | 469 | * @return EE_Addon |
470 | 470 | */ |
471 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
471 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
472 | 472 | // retrieve instantiated class |
473 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
473 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -502,27 +502,27 @@ discard block |
||
502 | 502 | $resolve_dependencies = false |
503 | 503 | ) { |
504 | 504 | // strip php file extension |
505 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
505 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
506 | 506 | // does the class have a prefix ? |
507 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
507 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
508 | 508 | // make sure $class_prefix is uppercase |
509 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
509 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
510 | 510 | // add class prefix ONCE!!! |
511 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
511 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
512 | 512 | } |
513 | 513 | // return object if it's already cached |
514 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
515 | - if ( $cached_class !== null ) { |
|
514 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
515 | + if ($cached_class !== null) { |
|
516 | 516 | return $cached_class; |
517 | 517 | } |
518 | 518 | // get full path to file |
519 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
519 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
520 | 520 | // load the file |
521 | - $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
521 | + $this->_require_file($path, $class_name, $type, $file_paths); |
|
522 | 522 | // instantiate the requested object |
523 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies ); |
|
523 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies); |
|
524 | 524 | // save it for later... kinda like gum { : $ |
525 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db, $cache ); |
|
525 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db, $cache); |
|
526 | 526 | return $class_obj; |
527 | 527 | } |
528 | 528 | |
@@ -543,21 +543,21 @@ discard block |
||
543 | 543 | * @param string $class_prefix |
544 | 544 | * @return null|object |
545 | 545 | */ |
546 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
547 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
548 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
546 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
547 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
548 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
549 | 549 | } else { |
550 | 550 | // have to specify something, but not anything that will conflict |
551 | 551 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
552 | 552 | } |
553 | 553 | // check if class has already been loaded, and return it if it has been |
554 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
554 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
555 | 555 | return $this->{$class_abbreviation}; |
556 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
556 | + } else if (isset ($this->{$class_name} )) { |
|
557 | 557 | return $this->{$class_name}; |
558 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
558 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
559 | 559 | return $this->LIB->{$class_name}; |
560 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
560 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
561 | 561 | return $this->addons->{$class_name}; |
562 | 562 | } |
563 | 563 | return null; |
@@ -578,20 +578,20 @@ discard block |
||
578 | 578 | * @param array $file_paths |
579 | 579 | * @return string | bool |
580 | 580 | */ |
581 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
581 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
582 | 582 | // make sure $file_paths is an array |
583 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
583 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
584 | 584 | // cycle thru paths |
585 | - foreach ( $file_paths as $key => $file_path ) { |
|
585 | + foreach ($file_paths as $key => $file_path) { |
|
586 | 586 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
587 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
587 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
588 | 588 | // prep file type |
589 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
589 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
590 | 590 | // build full file path |
591 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
591 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
592 | 592 | //does the file exist and can be read ? |
593 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
594 | - return $file_paths[ $key ]; |
|
593 | + if (is_readable($file_paths[$key])) { |
|
594 | + return $file_paths[$key]; |
|
595 | 595 | } |
596 | 596 | } |
597 | 597 | return false; |
@@ -613,29 +613,29 @@ discard block |
||
613 | 613 | * @return void |
614 | 614 | * @throws \EE_Error |
615 | 615 | */ |
616 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
616 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
617 | 617 | // don't give up! you gotta... |
618 | 618 | try { |
619 | 619 | //does the file exist and can it be read ? |
620 | - if ( ! $path ) { |
|
620 | + if ( ! $path) { |
|
621 | 621 | // so sorry, can't find the file |
622 | - throw new EE_Error ( |
|
622 | + throw new EE_Error( |
|
623 | 623 | sprintf( |
624 | - __( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ), |
|
625 | - trim( $type, '.' ), |
|
624 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
625 | + trim($type, '.'), |
|
626 | 626 | $class_name, |
627 | - '<br />' . implode( ',<br />', $file_paths ) |
|
627 | + '<br />'.implode(',<br />', $file_paths) |
|
628 | 628 | ) |
629 | 629 | ); |
630 | 630 | } |
631 | 631 | // get the file |
632 | - require_once( $path ); |
|
632 | + require_once($path); |
|
633 | 633 | // if the class isn't already declared somewhere |
634 | - if ( class_exists( $class_name, false ) === false ) { |
|
634 | + if (class_exists($class_name, false) === false) { |
|
635 | 635 | // so sorry, not a class |
636 | 636 | throw new EE_Error( |
637 | 637 | sprintf( |
638 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
638 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
639 | 639 | $type, |
640 | 640 | $path, |
641 | 641 | $class_name |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | ); |
644 | 644 | } |
645 | 645 | |
646 | - } catch ( EE_Error $e ) { |
|
646 | + } catch (EE_Error $e) { |
|
647 | 647 | $e->get_error(); |
648 | 648 | } |
649 | 649 | } |
@@ -675,61 +675,61 @@ discard block |
||
675 | 675 | * @return null | object |
676 | 676 | * @throws \EE_Error |
677 | 677 | */ |
678 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = false ) { |
|
678 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = false) { |
|
679 | 679 | $class_obj = null; |
680 | - $resolve_dependencies = isset( $this->_auto_resolve_dependencies[ $class_name ] ) && empty( $arguments ) |
|
680 | + $resolve_dependencies = isset($this->_auto_resolve_dependencies[$class_name]) && empty($arguments) |
|
681 | 681 | ? true |
682 | 682 | : $resolve_dependencies; |
683 | 683 | // don't give up! you gotta... |
684 | 684 | try { |
685 | 685 | // create reflection |
686 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
686 | + $reflector = $this->get_ReflectionClass($class_name); |
|
687 | 687 | // make sure arguments are an array |
688 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
688 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
689 | 689 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
690 | 690 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
691 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
691 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
692 | 692 | ? $arguments |
693 | - : array( $arguments ); |
|
693 | + : array($arguments); |
|
694 | 694 | // attempt to inject dependencies ? |
695 | 695 | if ( |
696 | 696 | $resolve_dependencies |
697 | 697 | && ! $from_db |
698 | 698 | && ! $load_only |
699 | - && ! $reflector->isSubclassOf( 'EE_Base_Class' ) |
|
699 | + && ! $reflector->isSubclassOf('EE_Base_Class') |
|
700 | 700 | ) { |
701 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
701 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
702 | 702 | } |
703 | 703 | // instantiate the class and add to the LIB array for tracking |
704 | 704 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
705 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() || $load_only ) { |
|
705 | + if ($reflector->getConstructor() === null || $reflector->isAbstract() || $load_only) { |
|
706 | 706 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
707 | 707 | //$instantiation_mode = "no constructor"; |
708 | 708 | return true; |
709 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
709 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
710 | 710 | //$instantiation_mode = "new_instance_from_db"; |
711 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
712 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
711 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
712 | + } else if (method_exists($class_name, 'new_instance')) { |
|
713 | 713 | //$instantiation_mode = "new_instance"; |
714 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
715 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
714 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
715 | + } else if (method_exists($class_name, 'instance')) { |
|
716 | 716 | //$instantiation_mode = "instance"; |
717 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
718 | - } else if ( $reflector->isInstantiable() ) { |
|
717 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
718 | + } else if ($reflector->isInstantiable()) { |
|
719 | 719 | //$instantiation_mode = "isInstantiable"; |
720 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
721 | - } else if ( ! $load_only ) { |
|
720 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
721 | + } else if ( ! $load_only) { |
|
722 | 722 | // heh ? something's not right ! |
723 | 723 | //$instantiation_mode = 'none'; |
724 | 724 | throw new EE_Error( |
725 | 725 | sprintf( |
726 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
726 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
727 | 727 | $type, |
728 | 728 | $class_name |
729 | 729 | ) |
730 | 730 | ); |
731 | 731 | } |
732 | - } catch ( EE_Error $e ) { |
|
732 | + } catch (EE_Error $e) { |
|
733 | 733 | $e->get_error(); |
734 | 734 | } |
735 | 735 | return $class_obj; |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | * @param array $array |
743 | 743 | * @return bool |
744 | 744 | */ |
745 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
746 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
745 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
746 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | |
@@ -758,14 +758,14 @@ discard block |
||
758 | 758 | * @param string $class_name |
759 | 759 | * @return ReflectionClass |
760 | 760 | */ |
761 | - public function get_ReflectionClass( $class_name ) { |
|
761 | + public function get_ReflectionClass($class_name) { |
|
762 | 762 | if ( |
763 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
764 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
763 | + ! isset($this->_reflectors[$class_name]) |
|
764 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
765 | 765 | ) { |
766 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
766 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
767 | 767 | } |
768 | - return $this->_reflectors[ $class_name ]; |
|
768 | + return $this->_reflectors[$class_name]; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -790,68 +790,68 @@ discard block |
||
790 | 790 | * @param array $arguments |
791 | 791 | * @return array |
792 | 792 | */ |
793 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
793 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
794 | 794 | // let's examine the constructor |
795 | 795 | $constructor = $reflector->getConstructor(); |
796 | 796 | // whu? huh? nothing? |
797 | - if ( ! $constructor ) { |
|
797 | + if ( ! $constructor) { |
|
798 | 798 | return $arguments; |
799 | 799 | } |
800 | 800 | // get constructor parameters |
801 | 801 | $params = $constructor->getParameters(); |
802 | 802 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
803 | - $argument_keys = array_keys( $arguments ); |
|
803 | + $argument_keys = array_keys($arguments); |
|
804 | 804 | // now loop thru all of the constructors expected parameters |
805 | - foreach ( $params as $index => $param ) { |
|
805 | + foreach ($params as $index => $param) { |
|
806 | 806 | // is this a dependency for a specific class ? |
807 | 807 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
808 | 808 | if ( |
809 | 809 | // param is not even a class |
810 | - empty( $param_class ) |
|
810 | + empty($param_class) |
|
811 | 811 | // and something already exists in the incoming arguments for this param |
812 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
812 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
813 | 813 | ) { |
814 | 814 | // so let's skip this argument and move on to the next |
815 | 815 | continue; |
816 | 816 | } else if ( |
817 | 817 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
818 | - ! empty( $param_class ) |
|
819 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
820 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
818 | + ! empty($param_class) |
|
819 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
820 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
821 | 821 | ) { |
822 | 822 | // skip this argument and move on to the next |
823 | 823 | continue; |
824 | 824 | } else if ( |
825 | 825 | // parameter is type hinted as a class, and should be injected |
826 | - ! empty( $param_class ) |
|
827 | - && isset( $this->_auto_resolve_dependencies[ $class_name ] ) |
|
828 | - && in_array( $param_class, $this->_auto_resolve_dependencies[ $class_name ] ) |
|
826 | + ! empty($param_class) |
|
827 | + && isset($this->_auto_resolve_dependencies[$class_name]) |
|
828 | + && in_array($param_class, $this->_auto_resolve_dependencies[$class_name]) |
|
829 | 829 | ) { |
830 | 830 | // we might have a dependency... let's try and find it in our cache |
831 | - $cached_class = $this->_get_cached_class( $param_class ); |
|
831 | + $cached_class = $this->_get_cached_class($param_class); |
|
832 | 832 | $dependency = null; |
833 | 833 | // and grab it if it exists |
834 | - if ( $cached_class instanceof $param_class ) { |
|
834 | + if ($cached_class instanceof $param_class) { |
|
835 | 835 | $dependency = $cached_class; |
836 | - } else if ( $param_class != $class_name ) { |
|
836 | + } else if ($param_class != $class_name) { |
|
837 | 837 | // or if not cached, then let's try and load it directly |
838 | - $core_class = $this->load_core( $param_class ); |
|
838 | + $core_class = $this->load_core($param_class); |
|
839 | 839 | // as long as we aren't creating some recursive loading loop |
840 | - if ( $core_class instanceof $param_class ) { |
|
840 | + if ($core_class instanceof $param_class) { |
|
841 | 841 | $dependency = $core_class; |
842 | 842 | } |
843 | 843 | } |
844 | 844 | // did we successfully find the correct dependency ? |
845 | - if ( $dependency instanceof $param_class ) { |
|
845 | + if ($dependency instanceof $param_class) { |
|
846 | 846 | // then let's inject it into the incoming array of arguments at the correct location |
847 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
848 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
847 | + if (isset($argument_keys[$index])) { |
|
848 | + $arguments[$argument_keys[$index]] = $dependency; |
|
849 | 849 | } else { |
850 | - $arguments[ $index ] = $dependency; |
|
850 | + $arguments[$index] = $dependency; |
|
851 | 851 | } |
852 | 852 | } |
853 | 853 | } else { |
854 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
854 | + $arguments[$index] = $param->getDefaultValue(); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | } |
@@ -880,16 +880,16 @@ discard block |
||
880 | 880 | * @param bool $cache |
881 | 881 | * @return void |
882 | 882 | */ |
883 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true ) { |
|
883 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true) { |
|
884 | 884 | // return newly instantiated class |
885 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
886 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
885 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
886 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
887 | 887 | $this->{$class_abbreviation} = $class_obj; |
888 | - } else if ( property_exists( $this, $class_name ) ) { |
|
888 | + } else if (property_exists($this, $class_name)) { |
|
889 | 889 | $this->{$class_name} = $class_obj; |
890 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
890 | + } else if ($class_prefix == 'addon' && $cache) { |
|
891 | 891 | $this->addons->{$class_name} = $class_obj; |
892 | - } else if ( ! $from_db && $cache ) { |
|
892 | + } else if ( ! $from_db && $cache) { |
|
893 | 893 | $this->LIB->{$class_name} = $class_obj; |
894 | 894 | } |
895 | 895 | } |
@@ -902,9 +902,9 @@ discard block |
||
902 | 902 | * @param string $name |
903 | 903 | * @return EE_Addon |
904 | 904 | */ |
905 | - public function get_addon_by_name( $name ) { |
|
906 | - foreach ( $this->addons as $addon ) { |
|
907 | - if ( $addon->name() == $name ) { |
|
905 | + public function get_addon_by_name($name) { |
|
906 | + foreach ($this->addons as $addon) { |
|
907 | + if ($addon->name() == $name) { |
|
908 | 908 | return $addon; |
909 | 909 | } |
910 | 910 | } |
@@ -920,8 +920,8 @@ discard block |
||
920 | 920 | */ |
921 | 921 | public function get_addons_by_name() { |
922 | 922 | $addons = array(); |
923 | - foreach ( $this->addons as $addon ) { |
|
924 | - $addons[ $addon->name() ] = $addon; |
|
923 | + foreach ($this->addons as $addon) { |
|
924 | + $addons[$addon->name()] = $addon; |
|
925 | 925 | } |
926 | 926 | return $addons; |
927 | 927 | } |
@@ -936,14 +936,14 @@ discard block |
||
936 | 936 | * @return \EEM_Base |
937 | 937 | * @throws \EE_Error |
938 | 938 | */ |
939 | - public function reset_model( $model_name ) { |
|
940 | - $model = $this->load_model( $model_name ); |
|
941 | - $model_class_name = get_class( $model ); |
|
939 | + public function reset_model($model_name) { |
|
940 | + $model = $this->load_model($model_name); |
|
941 | + $model_class_name = get_class($model); |
|
942 | 942 | //get that model reset it and make sure we nuke the old reference to it |
943 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
943 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
944 | 944 | $this->LIB->$model_class_name = $model::reset(); |
945 | 945 | } else { |
946 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
946 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
947 | 947 | } |
948 | 948 | return $this->LIB->$model_class_name; |
949 | 949 | } |
@@ -961,15 +961,15 @@ discard block |
||
961 | 961 | * currently reinstantiate the singletons at the moment) |
962 | 962 | * @return EE_Registry |
963 | 963 | */ |
964 | - public static function reset( $hard = false, $reinstantiate = true ) { |
|
964 | + public static function reset($hard = false, $reinstantiate = true) { |
|
965 | 965 | $instance = self::instance(); |
966 | - $instance->load_helper( 'Activation' ); |
|
966 | + $instance->load_helper('Activation'); |
|
967 | 967 | EEH_Activation::reset(); |
968 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
968 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
969 | 969 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
970 | 970 | $instance->LIB = new stdClass(); |
971 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
972 | - $instance->reset_model( $model_name ); |
|
971 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
972 | + $instance->reset_model($model_name); |
|
973 | 973 | } |
974 | 974 | return $instance; |
975 | 975 | } |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | * @param $a |
990 | 990 | * @param $b |
991 | 991 | */ |
992 | - final function __call( $a, $b ) { |
|
992 | + final function __call($a, $b) { |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | /** |
998 | 998 | * @param $a |
999 | 999 | */ |
1000 | - final function __get( $a ) { |
|
1000 | + final function __get($a) { |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | * @param $a |
1007 | 1007 | * @param $b |
1008 | 1008 | */ |
1009 | - final function __set( $a, $b ) { |
|
1009 | + final function __set($a, $b) { |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | /** |
1015 | 1015 | * @param $a |
1016 | 1016 | */ |
1017 | - final function __isset( $a ) { |
|
1017 | + final function __isset($a) { |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | /** |
1023 | 1023 | * @param $a |
1024 | 1024 | */ |
1025 | - final function __unset( $a ) { |
|
1025 | + final function __unset($a) { |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | * @param $a |
1070 | 1070 | * @param $b |
1071 | 1071 | */ |
1072 | - final static function __callStatic( $a, $b ) { |
|
1072 | + final static function __callStatic($a, $b) { |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | /** |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | */ |
1079 | 1079 | public function cpt_models() { |
1080 | 1080 | $cpt_models = array(); |
1081 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1082 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1083 | - $cpt_models[ $short_name ] = $classname; |
|
1081 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1082 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1083 | + $cpt_models[$short_name] = $classname; |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | return $cpt_models; |