@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @param \EE_Dependency_Map $dependency_map |
| 179 | 179 | * @return \EE_Registry instance |
| 180 | 180 | */ |
| 181 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
| 181 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
| 182 | 182 | // check if class object is instantiated |
| 183 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
| 184 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
| 183 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
| 184 | + self::$_instance = new EE_Registry($dependency_map); |
|
| 185 | 185 | } |
| 186 | 186 | return self::$_instance; |
| 187 | 187 | } |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | * @param \EE_Dependency_Map $dependency_map |
| 197 | 197 | * @return \EE_Registry |
| 198 | 198 | */ |
| 199 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
| 199 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
| 200 | 200 | $this->_dependency_map = $dependency_map; |
| 201 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
| 201 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -225,19 +225,19 @@ discard block |
||
| 225 | 225 | $this->modules = new StdClass(); |
| 226 | 226 | $this->shortcodes = new StdClass(); |
| 227 | 227 | $this->widgets = new StdClass(); |
| 228 | - $this->load_core( 'Base', array(), true ); |
|
| 228 | + $this->load_core('Base', array(), true); |
|
| 229 | 229 | // add our request and response objects to the cache |
| 230 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
| 230 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
| 231 | 231 | $this->_set_cached_class( |
| 232 | 232 | $request_loader(), |
| 233 | 233 | 'EE_Request' |
| 234 | 234 | ); |
| 235 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
| 235 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
| 236 | 236 | $this->_set_cached_class( |
| 237 | 237 | $response_loader(), |
| 238 | 238 | 'EE_Response' |
| 239 | 239 | ); |
| 240 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
| 240 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | |
@@ -250,10 +250,10 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function init() { |
| 252 | 252 | // Get current page protocol |
| 253 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
| 253 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
| 254 | 254 | // Output admin-ajax.php URL with same protocol as current page |
| 255 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
| 256 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
| 255 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
| 256 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | 266 | public static function localize_i18n_js_strings() { |
| 267 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
| 268 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
| 269 | - if ( is_scalar( $value ) ) { |
|
| 270 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
| 267 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
| 268 | + foreach ($i18n_js_strings as $key => $value) { |
|
| 269 | + if (is_scalar($value)) { |
|
| 270 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
| 274 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | |
@@ -279,15 +279,15 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @param mixed string | EED_Module $module |
| 281 | 281 | */ |
| 282 | - public function add_module( $module ) { |
|
| 283 | - if ( $module instanceof EED_Module ) { |
|
| 284 | - $module_class = get_class( $module ); |
|
| 282 | + public function add_module($module) { |
|
| 283 | + if ($module instanceof EED_Module) { |
|
| 284 | + $module_class = get_class($module); |
|
| 285 | 285 | $this->modules->{$module_class} = $module; |
| 286 | 286 | } else { |
| 287 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
| 288 | - $this->load_core( 'Module_Request_Router' ); |
|
| 287 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
| 288 | + $this->load_core('Module_Request_Router'); |
|
| 289 | 289 | } |
| 290 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
| 290 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | * @param string $module_name |
| 298 | 298 | * @return mixed EED_Module | NULL |
| 299 | 299 | */ |
| 300 | - public function get_module( $module_name = '' ) { |
|
| 301 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 300 | + public function get_module($module_name = '') { |
|
| 301 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
@@ -312,20 +312,20 @@ discard block |
||
| 312 | 312 | * @param bool $load_only |
| 313 | 313 | * @return mixed |
| 314 | 314 | */ |
| 315 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
| 315 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
| 316 | 316 | $core_paths = apply_filters( |
| 317 | 317 | 'FHEE__EE_Registry__load_core__core_paths', |
| 318 | 318 | array( |
| 319 | 319 | EE_CORE, |
| 320 | 320 | EE_ADMIN, |
| 321 | 321 | EE_CPTS, |
| 322 | - EE_CORE . 'data_migration_scripts' . DS, |
|
| 323 | - EE_CORE . 'request_stack' . DS, |
|
| 324 | - EE_CORE . 'middleware' . DS, |
|
| 322 | + EE_CORE.'data_migration_scripts'.DS, |
|
| 323 | + EE_CORE.'request_stack'.DS, |
|
| 324 | + EE_CORE.'middleware'.DS, |
|
| 325 | 325 | ) |
| 326 | 326 | ); |
| 327 | 327 | // retrieve instantiated class |
| 328 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
| 328 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | * @param bool $load_only |
| 340 | 340 | * @return mixed |
| 341 | 341 | */ |
| 342 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
| 342 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
| 343 | 343 | $service_paths = apply_filters( |
| 344 | 344 | 'FHEE__EE_Registry__load_service__service_paths', |
| 345 | 345 | array( |
| 346 | - EE_CORE . 'services' . DS, |
|
| 346 | + EE_CORE.'services'.DS, |
|
| 347 | 347 | ) |
| 348 | 348 | ); |
| 349 | 349 | // retrieve instantiated class |
| 350 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
| 350 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | * @param mixed $arguments |
| 361 | 361 | * @return EE_Data_Migration_Script_Base |
| 362 | 362 | */ |
| 363 | - public function load_dms( $class_name, $arguments = array() ) { |
|
| 363 | + public function load_dms($class_name, $arguments = array()) { |
|
| 364 | 364 | // retrieve instantiated class |
| 365 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
| 365 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | |
@@ -377,14 +377,14 @@ discard block |
||
| 377 | 377 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
| 378 | 378 | * @return EE_Base_Class | bool |
| 379 | 379 | */ |
| 380 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
| 381 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
| 380 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
| 381 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
| 382 | 382 | EE_CORE, |
| 383 | 383 | EE_CLASSES, |
| 384 | 384 | EE_BUSINESS |
| 385 | - ) ); |
|
| 385 | + )); |
|
| 386 | 386 | // retrieve instantiated class |
| 387 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
| 387 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | |
@@ -397,11 +397,11 @@ discard block |
||
| 397 | 397 | * @param bool $load_only |
| 398 | 398 | * @return EEH_Base | bool |
| 399 | 399 | */ |
| 400 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
| 400 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
| 401 | 401 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
| 402 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
| 402 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
| 403 | 403 | // retrieve instantiated class |
| 404 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
| 404 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | |
@@ -416,16 +416,16 @@ discard block |
||
| 416 | 416 | * @param bool $cache whether to cache the object or not. |
| 417 | 417 | * @return mixed |
| 418 | 418 | */ |
| 419 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
| 419 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
| 420 | 420 | $paths = array( |
| 421 | 421 | EE_LIBRARIES, |
| 422 | - EE_LIBRARIES . 'messages' . DS, |
|
| 423 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
| 424 | - EE_LIBRARIES . 'qtips' . DS, |
|
| 425 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
| 422 | + EE_LIBRARIES.'messages'.DS, |
|
| 423 | + EE_LIBRARIES.'shortcodes'.DS, |
|
| 424 | + EE_LIBRARIES.'qtips'.DS, |
|
| 425 | + EE_LIBRARIES.'payment_methods'.DS, |
|
| 426 | 426 | ); |
| 427 | 427 | // retrieve instantiated class |
| 428 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
| 428 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | |
@@ -438,13 +438,13 @@ discard block |
||
| 438 | 438 | * @param bool $load_only |
| 439 | 439 | * @return EEM_Base | bool |
| 440 | 440 | */ |
| 441 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
| 442 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
| 441 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
| 442 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
| 443 | 443 | EE_MODELS, |
| 444 | 444 | EE_CORE |
| 445 | - ) ); |
|
| 445 | + )); |
|
| 446 | 446 | // retrieve instantiated class |
| 447 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
| 447 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
@@ -457,15 +457,15 @@ discard block |
||
| 457 | 457 | * @param bool $load_only |
| 458 | 458 | * @return mixed | bool |
| 459 | 459 | */ |
| 460 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
| 460 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
| 461 | 461 | $paths = array( |
| 462 | - EE_MODELS . 'fields' . DS, |
|
| 463 | - EE_MODELS . 'helpers' . DS, |
|
| 464 | - EE_MODELS . 'relations' . DS, |
|
| 465 | - EE_MODELS . 'strategies' . DS |
|
| 462 | + EE_MODELS.'fields'.DS, |
|
| 463 | + EE_MODELS.'helpers'.DS, |
|
| 464 | + EE_MODELS.'relations'.DS, |
|
| 465 | + EE_MODELS.'strategies'.DS |
|
| 466 | 466 | ); |
| 467 | 467 | // retrieve instantiated class |
| 468 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
| 468 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | |
@@ -475,8 +475,8 @@ discard block |
||
| 475 | 475 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
| 476 | 476 | * @return boolean |
| 477 | 477 | */ |
| 478 | - public function is_model_name( $model_name ) { |
|
| 479 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
| 478 | + public function is_model_name($model_name) { |
|
| 479 | + return isset($this->models[$model_name]) ? true : false; |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | * @param bool $load_only |
| 492 | 492 | * @return mixed |
| 493 | 493 | */ |
| 494 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
| 494 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
| 495 | 495 | // retrieve instantiated class |
| 496 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
| 496 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | |
@@ -508,9 +508,9 @@ discard block |
||
| 508 | 508 | * @param bool $load_only |
| 509 | 509 | * @return EE_Addon |
| 510 | 510 | */ |
| 511 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
| 511 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
| 512 | 512 | // retrieve instantiated class |
| 513 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
| 513 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | |
@@ -541,46 +541,46 @@ discard block |
||
| 541 | 541 | $load_only = false |
| 542 | 542 | ) { |
| 543 | 543 | // strip php file extension |
| 544 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
| 544 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
| 545 | 545 | // does the class have a prefix ? |
| 546 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
| 546 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
| 547 | 547 | // make sure $class_prefix is uppercase |
| 548 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
| 548 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
| 549 | 549 | // add class prefix ONCE!!! |
| 550 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
| 550 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
| 551 | 551 | } |
| 552 | - $class_exists = class_exists( $class_name ); |
|
| 552 | + $class_exists = class_exists($class_name); |
|
| 553 | 553 | // if we're only loading the class and it already exists, then let's just return true immediately |
| 554 | - if ( $load_only && $class_exists ) { |
|
| 554 | + if ($load_only && $class_exists) { |
|
| 555 | 555 | return true; |
| 556 | 556 | } |
| 557 | 557 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
| 558 | 558 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
| 559 | 559 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
| 560 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
| 560 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
| 561 | 561 | // return object if it's already cached |
| 562 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
| 563 | - if ( $cached_class !== null ) { |
|
| 562 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
| 563 | + if ($cached_class !== null) { |
|
| 564 | 564 | return $cached_class; |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | // if the class doesn't already exist.. then we need to try and find the file and load it |
| 568 | - if ( ! $class_exists ) { |
|
| 568 | + if ( ! $class_exists) { |
|
| 569 | 569 | // get full path to file |
| 570 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
| 570 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
| 571 | 571 | // load the file |
| 572 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
| 572 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
| 573 | 573 | // if loading failed, or we are only loading a file but NOT instantiating an object |
| 574 | - if ( ! $loaded || $load_only ) { |
|
| 574 | + if ( ! $loaded || $load_only) { |
|
| 575 | 575 | // return boolean if only loading, or null if an object was expected |
| 576 | 576 | return $load_only ? $loaded : null; |
| 577 | 577 | } |
| 578 | 578 | } |
| 579 | 579 | // instantiate the requested object |
| 580 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
| 581 | - if ( $this->_cache_on && $cache ) { |
|
| 580 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
| 581 | + if ($this->_cache_on && $cache) { |
|
| 582 | 582 | // save it for later... kinda like gum { : $ |
| 583 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
| 583 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
| 584 | 584 | } |
| 585 | 585 | $this->_cache_on = true; |
| 586 | 586 | return $class_obj; |
@@ -603,24 +603,24 @@ discard block |
||
| 603 | 603 | * @param string $class_prefix |
| 604 | 604 | * @return null|object |
| 605 | 605 | */ |
| 606 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
| 607 | - if ( $class_name === 'EE_Registry' ) { |
|
| 606 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
| 607 | + if ($class_name === 'EE_Registry') { |
|
| 608 | 608 | return $this; |
| 609 | 609 | } |
| 610 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 611 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 610 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 611 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 612 | 612 | } else { |
| 613 | 613 | // have to specify something, but not anything that will conflict |
| 614 | 614 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
| 615 | 615 | } |
| 616 | 616 | // check if class has already been loaded, and return it if it has been |
| 617 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
| 617 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
| 618 | 618 | return $this->{$class_abbreviation}; |
| 619 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
| 619 | + } else if (isset ($this->{$class_name} )) { |
|
| 620 | 620 | return $this->{$class_name}; |
| 621 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
| 621 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
| 622 | 622 | return $this->LIB->{$class_name}; |
| 623 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
| 623 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
| 624 | 624 | return $this->addons->{$class_name}; |
| 625 | 625 | } |
| 626 | 626 | return null; |
@@ -641,20 +641,20 @@ discard block |
||
| 641 | 641 | * @param array $file_paths |
| 642 | 642 | * @return string | bool |
| 643 | 643 | */ |
| 644 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
| 644 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
| 645 | 645 | // make sure $file_paths is an array |
| 646 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
| 646 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
| 647 | 647 | // cycle thru paths |
| 648 | - foreach ( $file_paths as $key => $file_path ) { |
|
| 648 | + foreach ($file_paths as $key => $file_path) { |
|
| 649 | 649 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
| 650 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
| 650 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
| 651 | 651 | // prep file type |
| 652 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
| 652 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
| 653 | 653 | // build full file path |
| 654 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
| 654 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
| 655 | 655 | //does the file exist and can be read ? |
| 656 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
| 657 | - return $file_paths[ $key ]; |
|
| 656 | + if (is_readable($file_paths[$key])) { |
|
| 657 | + return $file_paths[$key]; |
|
| 658 | 658 | } |
| 659 | 659 | } |
| 660 | 660 | return false; |
@@ -676,29 +676,29 @@ discard block |
||
| 676 | 676 | * @return boolean |
| 677 | 677 | * @throws \EE_Error |
| 678 | 678 | */ |
| 679 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
| 679 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
| 680 | 680 | // don't give up! you gotta... |
| 681 | 681 | try { |
| 682 | 682 | //does the file exist and can it be read ? |
| 683 | - if ( ! $path ) { |
|
| 683 | + if ( ! $path) { |
|
| 684 | 684 | // so sorry, can't find the file |
| 685 | - throw new EE_Error ( |
|
| 685 | + throw new EE_Error( |
|
| 686 | 686 | sprintf( |
| 687 | - __( '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' ), |
|
| 688 | - trim( $type, '.' ), |
|
| 687 | + __('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'), |
|
| 688 | + trim($type, '.'), |
|
| 689 | 689 | $class_name, |
| 690 | - '<br />' . implode( ',<br />', $file_paths ) |
|
| 690 | + '<br />'.implode(',<br />', $file_paths) |
|
| 691 | 691 | ) |
| 692 | 692 | ); |
| 693 | 693 | } |
| 694 | 694 | // get the file |
| 695 | - require_once( $path ); |
|
| 695 | + require_once($path); |
|
| 696 | 696 | // if the class isn't already declared somewhere |
| 697 | - if ( class_exists( $class_name, false ) === false ) { |
|
| 697 | + if (class_exists($class_name, false) === false) { |
|
| 698 | 698 | // so sorry, not a class |
| 699 | 699 | throw new EE_Error( |
| 700 | 700 | sprintf( |
| 701 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
| 701 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
| 702 | 702 | $type, |
| 703 | 703 | $path, |
| 704 | 704 | $class_name |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | ); |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - } catch ( EE_Error $e ) { |
|
| 709 | + } catch (EE_Error $e) { |
|
| 710 | 710 | $e->get_error(); |
| 711 | 711 | return false; |
| 712 | 712 | } |
@@ -738,55 +738,55 @@ discard block |
||
| 738 | 738 | * @return null | object |
| 739 | 739 | * @throws \EE_Error |
| 740 | 740 | */ |
| 741 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
| 741 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
| 742 | 742 | $class_obj = null; |
| 743 | 743 | // don't give up! you gotta... |
| 744 | 744 | try { |
| 745 | 745 | // create reflection |
| 746 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
| 746 | + $reflector = $this->get_ReflectionClass($class_name); |
|
| 747 | 747 | // make sure arguments are an array |
| 748 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
| 748 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
| 749 | 749 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
| 750 | 750 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
| 751 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
| 751 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
| 752 | 752 | ? $arguments |
| 753 | - : array( $arguments ); |
|
| 753 | + : array($arguments); |
|
| 754 | 754 | // attempt to inject dependencies ? |
| 755 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
| 756 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
| 755 | + if ($this->_dependency_map->has($class_name)) { |
|
| 756 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
| 757 | 757 | } |
| 758 | 758 | // instantiate the class and add to the LIB array for tracking |
| 759 | 759 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
| 760 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) { |
|
| 760 | + if ($reflector->getConstructor() === null || $reflector->isAbstract()) { |
|
| 761 | 761 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
| 762 | 762 | //$instantiation_mode = "no constructor"; |
| 763 | 763 | $class_obj = true; |
| 764 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
| 764 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
| 765 | 765 | //$instantiation_mode = "new_instance_from_db"; |
| 766 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
| 767 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
| 766 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
| 767 | + } else if (method_exists($class_name, 'new_instance')) { |
|
| 768 | 768 | //$instantiation_mode = "new_instance"; |
| 769 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
| 770 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
| 769 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
| 770 | + } else if (method_exists($class_name, 'instance')) { |
|
| 771 | 771 | //$instantiation_mode = "instance"; |
| 772 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
| 773 | - } else if ( $reflector->isInstantiable() ) { |
|
| 772 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
| 773 | + } else if ($reflector->isInstantiable()) { |
|
| 774 | 774 | //$instantiation_mode = "isInstantiable"; |
| 775 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
| 775 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
| 776 | 776 | } else { |
| 777 | 777 | // heh ? something's not right ! |
| 778 | 778 | //$instantiation_mode = 'none'; |
| 779 | 779 | throw new EE_Error( |
| 780 | 780 | sprintf( |
| 781 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
| 781 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
| 782 | 782 | $type, |
| 783 | 783 | $class_name |
| 784 | 784 | ) |
| 785 | 785 | ); |
| 786 | 786 | } |
| 787 | - } catch ( Exception $e ) { |
|
| 788 | - if ( ! $e instanceof EE_Error ) { |
|
| 789 | - $e = new EE_Error( $e->getMessage() ); |
|
| 787 | + } catch (Exception $e) { |
|
| 788 | + if ( ! $e instanceof EE_Error) { |
|
| 789 | + $e = new EE_Error($e->getMessage()); |
|
| 790 | 790 | } |
| 791 | 791 | $e->get_error(); |
| 792 | 792 | } |
@@ -800,8 +800,8 @@ discard block |
||
| 800 | 800 | * @param array $array |
| 801 | 801 | * @return bool |
| 802 | 802 | */ |
| 803 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
| 804 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
| 803 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
| 804 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | |
@@ -816,14 +816,14 @@ discard block |
||
| 816 | 816 | * @param string $class_name |
| 817 | 817 | * @return ReflectionClass |
| 818 | 818 | */ |
| 819 | - public function get_ReflectionClass( $class_name ) { |
|
| 819 | + public function get_ReflectionClass($class_name) { |
|
| 820 | 820 | if ( |
| 821 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
| 822 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
| 821 | + ! isset($this->_reflectors[$class_name]) |
|
| 822 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
| 823 | 823 | ) { |
| 824 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
| 824 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
| 825 | 825 | } |
| 826 | - return $this->_reflectors[ $class_name ]; |
|
| 826 | + return $this->_reflectors[$class_name]; |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | |
@@ -848,45 +848,45 @@ discard block |
||
| 848 | 848 | * @param array $arguments |
| 849 | 849 | * @return array |
| 850 | 850 | */ |
| 851 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
| 851 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
| 852 | 852 | // let's examine the constructor |
| 853 | 853 | $constructor = $reflector->getConstructor(); |
| 854 | 854 | // whu? huh? nothing? |
| 855 | - if ( ! $constructor ) { |
|
| 855 | + if ( ! $constructor) { |
|
| 856 | 856 | return $arguments; |
| 857 | 857 | } |
| 858 | 858 | // get constructor parameters |
| 859 | 859 | $params = $constructor->getParameters(); |
| 860 | 860 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
| 861 | - $argument_keys = array_keys( $arguments ); |
|
| 861 | + $argument_keys = array_keys($arguments); |
|
| 862 | 862 | // now loop thru all of the constructors expected parameters |
| 863 | - foreach ( $params as $index => $param ) { |
|
| 863 | + foreach ($params as $index => $param) { |
|
| 864 | 864 | // is this a dependency for a specific class ? |
| 865 | 865 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
| 866 | 866 | if ( |
| 867 | 867 | // param is not even a class |
| 868 | - empty( $param_class ) |
|
| 868 | + empty($param_class) |
|
| 869 | 869 | // and something already exists in the incoming arguments for this param |
| 870 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
| 870 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
| 871 | 871 | ) { |
| 872 | 872 | // so let's skip this argument and move on to the next |
| 873 | 873 | continue; |
| 874 | 874 | } else if ( |
| 875 | 875 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
| 876 | - ! empty( $param_class ) |
|
| 877 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
| 878 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
| 876 | + ! empty($param_class) |
|
| 877 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
| 878 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
| 879 | 879 | ) { |
| 880 | 880 | // skip this argument and move on to the next |
| 881 | 881 | continue; |
| 882 | 882 | } else if ( |
| 883 | 883 | // parameter is type hinted as a class, and should be injected |
| 884 | - ! empty( $param_class ) |
|
| 885 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
| 884 | + ! empty($param_class) |
|
| 885 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
| 886 | 886 | ) { |
| 887 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
| 887 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
| 888 | 888 | } else { |
| 889 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
| 889 | + $arguments[$index] = $param->getDefaultValue(); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | } |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * @param mixed $index |
| 904 | 904 | * @return array |
| 905 | 905 | */ |
| 906 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
| 906 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
| 907 | 907 | $dependency = null; |
| 908 | 908 | // should dependency be loaded from cache ? |
| 909 | 909 | $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( |
@@ -913,30 +913,30 @@ discard block |
||
| 913 | 913 | : false; |
| 914 | 914 | // we might have a dependency... |
| 915 | 915 | // let's MAYBE try and find it in our cache if that's what's been requested |
| 916 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
| 916 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
| 917 | 917 | // and grab it if it exists |
| 918 | - if ( $cached_class instanceof $param_class ) { |
|
| 918 | + if ($cached_class instanceof $param_class) { |
|
| 919 | 919 | $dependency = $cached_class; |
| 920 | - } else if ( $param_class != $class_name ) { |
|
| 920 | + } else if ($param_class != $class_name) { |
|
| 921 | 921 | // obtain the loader method from the dependency map |
| 922 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
| 922 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
| 923 | 923 | // is loader a custom closure ? |
| 924 | - if ( $loader instanceof Closure ) { |
|
| 924 | + if ($loader instanceof Closure) { |
|
| 925 | 925 | $dependency = $loader(); |
| 926 | 926 | } else { |
| 927 | 927 | // set the cache on property for the recursive loading call |
| 928 | 928 | $this->_cache_on = $cache_on; |
| 929 | 929 | // if not, then let's try and load it via the registry |
| 930 | - $dependency = $this->{$loader}( $param_class ); |
|
| 930 | + $dependency = $this->{$loader}($param_class); |
|
| 931 | 931 | } |
| 932 | 932 | } |
| 933 | 933 | // did we successfully find the correct dependency ? |
| 934 | - if ( $dependency instanceof $param_class ) { |
|
| 934 | + if ($dependency instanceof $param_class) { |
|
| 935 | 935 | // then let's inject it into the incoming array of arguments at the correct location |
| 936 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
| 937 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
| 936 | + if (isset($argument_keys[$index])) { |
|
| 937 | + $arguments[$argument_keys[$index]] = $dependency; |
|
| 938 | 938 | } else { |
| 939 | - $arguments[ $index ] = $dependency; |
|
| 939 | + $arguments[$index] = $dependency; |
|
| 940 | 940 | } |
| 941 | 941 | } |
| 942 | 942 | return $arguments; |
@@ -961,19 +961,19 @@ discard block |
||
| 961 | 961 | * @param bool $from_db |
| 962 | 962 | * @return void |
| 963 | 963 | */ |
| 964 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
| 965 | - if ( $class_name === 'EE_Registry' ) { |
|
| 964 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
| 965 | + if ($class_name === 'EE_Registry') { |
|
| 966 | 966 | return; |
| 967 | 967 | } |
| 968 | 968 | // return newly instantiated class |
| 969 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 970 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 969 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 970 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 971 | 971 | $this->{$class_abbreviation} = $class_obj; |
| 972 | - } else if ( property_exists( $this, $class_name ) ) { |
|
| 972 | + } else if (property_exists($this, $class_name)) { |
|
| 973 | 973 | $this->{$class_name} = $class_obj; |
| 974 | - } else if ( $class_prefix == 'addon' ) { |
|
| 974 | + } else if ($class_prefix == 'addon') { |
|
| 975 | 975 | $this->addons->{$class_name} = $class_obj; |
| 976 | - } else if ( ! $from_db ) { |
|
| 976 | + } else if ( ! $from_db) { |
|
| 977 | 977 | $this->LIB->{$class_name} = $class_obj; |
| 978 | 978 | } |
| 979 | 979 | } |
@@ -990,12 +990,12 @@ discard block |
||
| 990 | 990 | * @param array $arguments |
| 991 | 991 | * @return object |
| 992 | 992 | */ |
| 993 | - public static function factory( $classname, $arguments = array() ) { |
|
| 994 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
| 995 | - if ( $loader instanceof Closure ) { |
|
| 996 | - return $loader( $arguments ); |
|
| 997 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
| 998 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
| 993 | + public static function factory($classname, $arguments = array()) { |
|
| 994 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
| 995 | + if ($loader instanceof Closure) { |
|
| 996 | + return $loader($arguments); |
|
| 997 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
| 998 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
| 999 | 999 | } |
| 1000 | 1000 | return null; |
| 1001 | 1001 | } |
@@ -1008,9 +1008,9 @@ discard block |
||
| 1008 | 1008 | * @param string $name |
| 1009 | 1009 | * @return EE_Addon |
| 1010 | 1010 | */ |
| 1011 | - public function get_addon_by_name( $name ) { |
|
| 1012 | - foreach ( $this->addons as $addon ) { |
|
| 1013 | - if ( $addon->name() == $name ) { |
|
| 1011 | + public function get_addon_by_name($name) { |
|
| 1012 | + foreach ($this->addons as $addon) { |
|
| 1013 | + if ($addon->name() == $name) { |
|
| 1014 | 1014 | return $addon; |
| 1015 | 1015 | } |
| 1016 | 1016 | } |
@@ -1026,8 +1026,8 @@ discard block |
||
| 1026 | 1026 | */ |
| 1027 | 1027 | public function get_addons_by_name() { |
| 1028 | 1028 | $addons = array(); |
| 1029 | - foreach ( $this->addons as $addon ) { |
|
| 1030 | - $addons[ $addon->name() ] = $addon; |
|
| 1029 | + foreach ($this->addons as $addon) { |
|
| 1030 | + $addons[$addon->name()] = $addon; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | return $addons; |
| 1033 | 1033 | } |
@@ -1042,14 +1042,14 @@ discard block |
||
| 1042 | 1042 | * @return \EEM_Base |
| 1043 | 1043 | * @throws \EE_Error |
| 1044 | 1044 | */ |
| 1045 | - public function reset_model( $model_name ) { |
|
| 1046 | - $model = $this->load_model( $model_name ); |
|
| 1047 | - $model_class_name = get_class( $model ); |
|
| 1045 | + public function reset_model($model_name) { |
|
| 1046 | + $model = $this->load_model($model_name); |
|
| 1047 | + $model_class_name = get_class($model); |
|
| 1048 | 1048 | //get that model reset it and make sure we nuke the old reference to it |
| 1049 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
| 1049 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
| 1050 | 1050 | $this->LIB->{$model_class_name} = $model::reset(); |
| 1051 | 1051 | } else { |
| 1052 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
| 1052 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | return $this->LIB->{$model_class_name}; |
| 1055 | 1055 | } |
@@ -1087,20 +1087,20 @@ discard block |
||
| 1087 | 1087 | * |
| 1088 | 1088 | * @return EE_Registry |
| 1089 | 1089 | */ |
| 1090 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
| 1090 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
| 1091 | 1091 | $instance = self::instance(); |
| 1092 | 1092 | $instance->_cache_on = true; |
| 1093 | 1093 | // reset some "special" classes |
| 1094 | 1094 | EEH_Activation::reset(); |
| 1095 | - $instance->CFG = $instance->CFG->reset( $hard, $reinstantiate ); |
|
| 1095 | + $instance->CFG = $instance->CFG->reset($hard, $reinstantiate); |
|
| 1096 | 1096 | $instance->CART = null; |
| 1097 | 1097 | $instance->MRM = null; |
| 1098 | 1098 | //handle of objects cached on LIB |
| 1099 | - foreach ( $instance->LIB as $class_name => $class ) { |
|
| 1100 | - if ( isset( $instance->LIB->{$class_name} ) ) { |
|
| 1101 | - if ( $instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\ResettableInterface ) { |
|
| 1102 | - if ( $instance->LIB->{$class_name} instanceof EEM_Base ) { |
|
| 1103 | - if ( $reset_models ) { |
|
| 1099 | + foreach ($instance->LIB as $class_name => $class) { |
|
| 1100 | + if (isset($instance->LIB->{$class_name} )) { |
|
| 1101 | + if ($instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\ResettableInterface) { |
|
| 1102 | + if ($instance->LIB->{$class_name} instanceof EEM_Base) { |
|
| 1103 | + if ($reset_models) { |
|
| 1104 | 1104 | $instance->LIB->{$class_name}->reset(); |
| 1105 | 1105 | } |
| 1106 | 1106 | continue; |
@@ -1108,8 +1108,8 @@ discard block |
||
| 1108 | 1108 | $instance->LIB->{$class_name}->reset(); |
| 1109 | 1109 | continue; |
| 1110 | 1110 | } |
| 1111 | - if ( ! $instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\InterminableInterface ) { |
|
| 1112 | - unset( $instance->LIB->{$class_name} ); |
|
| 1111 | + if ( ! $instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\InterminableInterface) { |
|
| 1112 | + unset($instance->LIB->{$class_name} ); |
|
| 1113 | 1113 | } |
| 1114 | 1114 | } |
| 1115 | 1115 | } |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | * @param $a |
| 1132 | 1132 | * @param $b |
| 1133 | 1133 | */ |
| 1134 | - final function __call( $a, $b ) { |
|
| 1134 | + final function __call($a, $b) { |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | |
@@ -1139,7 +1139,7 @@ discard block |
||
| 1139 | 1139 | /** |
| 1140 | 1140 | * @param $a |
| 1141 | 1141 | */ |
| 1142 | - final function __get( $a ) { |
|
| 1142 | + final function __get($a) { |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | * @param $a |
| 1149 | 1149 | * @param $b |
| 1150 | 1150 | */ |
| 1151 | - final function __set( $a, $b ) { |
|
| 1151 | + final function __set($a, $b) { |
|
| 1152 | 1152 | } |
| 1153 | 1153 | |
| 1154 | 1154 | |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | /** |
| 1157 | 1157 | * @param $a |
| 1158 | 1158 | */ |
| 1159 | - final function __isset( $a ) { |
|
| 1159 | + final function __isset($a) { |
|
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | 1162 | |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | /** |
| 1165 | 1165 | * @param $a |
| 1166 | 1166 | */ |
| 1167 | - final function __unset( $a ) { |
|
| 1167 | + final function __unset($a) { |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | 1170 | |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | * @param $a |
| 1212 | 1212 | * @param $b |
| 1213 | 1213 | */ |
| 1214 | - final static function __callStatic( $a, $b ) { |
|
| 1214 | + final static function __callStatic($a, $b) { |
|
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | 1217 | /** |
@@ -1220,9 +1220,9 @@ discard block |
||
| 1220 | 1220 | */ |
| 1221 | 1221 | public function cpt_models() { |
| 1222 | 1222 | $cpt_models = array(); |
| 1223 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
| 1224 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
| 1225 | - $cpt_models[ $short_name ] = $classname; |
|
| 1223 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
| 1224 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
| 1225 | + $cpt_models[$short_name] = $classname; |
|
| 1226 | 1226 | } |
| 1227 | 1227 | } |
| 1228 | 1228 | return $cpt_models; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | /** |
| 6 | 6 | * |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function __construct() { |
| 53 | 53 | // PSR4 Autoloaders |
| 54 | - espresso_load_required( 'EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php' ); |
|
| 54 | + espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE.'EE_Psr4AutoloaderInit.core.php'); |
|
| 55 | 55 | EE_Psr4AutoloaderInit::initialize_psr4_loader(); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -68,24 +68,24 @@ discard block |
||
| 68 | 68 | * @param EE_Response $response |
| 69 | 69 | * @return EE_Response |
| 70 | 70 | */ |
| 71 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 71 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
| 72 | 72 | $this->request = $request; |
| 73 | 73 | $this->response = $response; |
| 74 | 74 | // info about how to load classes required by other classes |
| 75 | 75 | $this->dependency_map = $this->_load_dependency_map(); |
| 76 | 76 | // central repository for classes |
| 77 | 77 | $this->registry = $this->_load_registry(); |
| 78 | - do_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading' ); |
|
| 78 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 79 | 79 | // workarounds for PHP < 5.3 |
| 80 | 80 | $this->_load_class_tools(); |
| 81 | 81 | // load interfaces |
| 82 | - espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' ); |
|
| 82 | + espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
| 83 | 83 | // deprecated functions |
| 84 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
| 84 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
| 85 | 85 | // WP cron jobs |
| 86 | - $this->registry->load_core( 'Cron_Tasks' ); |
|
| 87 | - $this->registry->load_core( 'EE_Request_Handler' ); |
|
| 88 | - $this->registry->load_core( 'EE_System' ); |
|
| 86 | + $this->registry->load_core('Cron_Tasks'); |
|
| 87 | + $this->registry->load_core('EE_Request_Handler'); |
|
| 88 | + $this->registry->load_core('EE_System'); |
|
| 89 | 89 | |
| 90 | 90 | return $this->response; |
| 91 | 91 | } |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | * @throws \EE_Error |
| 116 | 116 | */ |
| 117 | 117 | public function dependency_map() { |
| 118 | - if ( ! $this->dependency_map instanceof EE_Dependency_Map ) { |
|
| 118 | + if ( ! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 119 | 119 | throw new EE_Error( |
| 120 | 120 | sprintf( |
| 121 | - __( 'Invalid EE_Dependency_Map: "%1$s"', 'event_espresso' ), |
|
| 122 | - print_r( $this->dependency_map, true ) |
|
| 121 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 122 | + print_r($this->dependency_map, true) |
|
| 123 | 123 | ) |
| 124 | 124 | ); |
| 125 | 125 | } |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | * @throws \EE_Error |
| 134 | 134 | */ |
| 135 | 135 | public function registry() { |
| 136 | - if ( ! $this->registry instanceof EE_Registry ) { |
|
| 136 | + if ( ! $this->registry instanceof EE_Registry) { |
|
| 137 | 137 | throw new EE_Error( |
| 138 | 138 | sprintf( |
| 139 | - __( 'Invalid EE_Registry: "%1$s"', 'event_espresso' ), |
|
| 140 | - print_r( $this->registry, true ) |
|
| 139 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 140 | + print_r($this->registry, true) |
|
| 141 | 141 | ) |
| 142 | 142 | ); |
| 143 | 143 | } |
@@ -153,15 +153,15 @@ discard block |
||
| 153 | 153 | * @return EE_Dependency_Map |
| 154 | 154 | */ |
| 155 | 155 | private function _load_dependency_map() { |
| 156 | - if ( ! is_readable( EE_CORE . 'EE_Dependency_Map.core.php' ) ) { |
|
| 156 | + if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) { |
|
| 157 | 157 | EE_Error::add_error( |
| 158 | - __( 'The EE_Dependency_Map core class could not be loaded.', 'event_espresso' ), |
|
| 158 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 159 | 159 | __FILE__, __FUNCTION__, __LINE__ |
| 160 | 160 | ); |
| 161 | - wp_die( EE_Error::get_notices() ); |
|
| 161 | + wp_die(EE_Error::get_notices()); |
|
| 162 | 162 | } |
| 163 | - require_once( EE_CORE . 'EE_Dependency_Map.core.php' ); |
|
| 164 | - return EE_Dependency_Map::instance( $this->request, $this->response ); |
|
| 163 | + require_once(EE_CORE.'EE_Dependency_Map.core.php'); |
|
| 164 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | * @return EE_Registry |
| 174 | 174 | */ |
| 175 | 175 | private function _load_registry() { |
| 176 | - if ( ! is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
| 176 | + if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
| 177 | 177 | EE_Error::add_error( |
| 178 | - __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ), |
|
| 178 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 179 | 179 | __FILE__, __FUNCTION__, __LINE__ |
| 180 | 180 | ); |
| 181 | - wp_die( EE_Error::get_notices() ); |
|
| 181 | + wp_die(EE_Error::get_notices()); |
|
| 182 | 182 | } |
| 183 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
| 184 | - return EE_Registry::instance( $this->dependency_map ); |
|
| 183 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
| 184 | + return EE_Registry::instance($this->dependency_map); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -192,13 +192,13 @@ discard block |
||
| 192 | 192 | * @return void |
| 193 | 193 | */ |
| 194 | 194 | private function _load_class_tools() { |
| 195 | - if ( ! is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
| 195 | + if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
| 196 | 196 | EE_Error::add_error( |
| 197 | - __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ), |
|
| 197 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 198 | 198 | __FILE__, __FUNCTION__, __LINE__ |
| 199 | 199 | ); |
| 200 | 200 | } |
| 201 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
| 201 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | * @param \EE_Request $request |
| 213 | 213 | * @param \EE_Response $response |
| 214 | 214 | */ |
| 215 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
| 215 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
| 216 | 216 | //\EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
| 217 | 217 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
| 218 | 218 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
| 219 | 219 | //die(); |
| 220 | - if ( $response->plugin_deactivated() ) { |
|
| 221 | - espresso_deactivate_plugin( EE_PLUGIN_BASENAME ); |
|
| 220 | + if ($response->plugin_deactivated()) { |
|
| 221 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |