@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | use EventEspresso\core\services\collections\CollectionInterface; |
11 | 11 | use EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface; |
12 | 12 | |
13 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
14 | - exit( 'No direct script access allowed' ); |
|
13 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
14 | + exit('No direct script access allowed'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | CollectionInterface $collection = null, |
79 | 79 | EE_Request $request = null |
80 | 80 | ) { |
81 | - $this->setDisplayStrategy( $display_strategy_name ); |
|
82 | - $this->setDefaultStep( $default_step ); |
|
83 | - $this->setFormStepUrlKey( $form_step_url_key ); |
|
84 | - if ( ! $collection instanceof CollectionInterface ) { |
|
85 | - $collection = new Collection( '\EventEspresso\core\services\progress_steps\ProgressStepInterface' ); |
|
81 | + $this->setDisplayStrategy($display_strategy_name); |
|
82 | + $this->setDefaultStep($default_step); |
|
83 | + $this->setFormStepUrlKey($form_step_url_key); |
|
84 | + if ( ! $collection instanceof CollectionInterface) { |
|
85 | + $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface'); |
|
86 | 86 | } |
87 | 87 | $this->collection = $collection; |
88 | - if ( ! $request instanceof EE_Request ) { |
|
89 | - $request = \EE_Registry::instance()->load_core( 'Request' ); |
|
88 | + if ( ! $request instanceof EE_Request) { |
|
89 | + $request = \EE_Registry::instance()->load_core('Request'); |
|
90 | 90 | } |
91 | 91 | $this->request = $request; |
92 | 92 | } |
@@ -98,28 +98,28 @@ discard block |
||
98 | 98 | * @throws InvalidDataTypeException |
99 | 99 | * @throws InvalidClassException |
100 | 100 | */ |
101 | - protected function setDisplayStrategy( $display_strategy_name = 'number_bubbles' ) { |
|
102 | - if ( ! is_string( $display_strategy_name ) ) { |
|
103 | - throw new InvalidDataTypeException( '$display_strategy_name', $display_strategy_name, 'string' ); |
|
101 | + protected function setDisplayStrategy($display_strategy_name = 'number_bubbles') { |
|
102 | + if ( ! is_string($display_strategy_name)) { |
|
103 | + throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string'); |
|
104 | 104 | } |
105 | 105 | // build up FQCN from incoming display strategy folder name |
106 | 106 | $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\'; |
107 | - $display_strategy_class .= $display_strategy_name . '\\'; |
|
108 | - $display_strategy_class .= str_replace( ' ', '', ucwords( str_replace( '_', ' ', $display_strategy_name ) ) ); |
|
107 | + $display_strategy_class .= $display_strategy_name.'\\'; |
|
108 | + $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name))); |
|
109 | 109 | $display_strategy_class .= 'ProgressStepsDisplay'; |
110 | 110 | $display_strategy_class = apply_filters( |
111 | 111 | 'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class', |
112 | 112 | $display_strategy_class |
113 | 113 | ); |
114 | - if ( ! class_exists( $display_strategy_class ) ) { |
|
115 | - throw new InvalidClassException( $display_strategy_class ); |
|
114 | + if ( ! class_exists($display_strategy_class)) { |
|
115 | + throw new InvalidClassException($display_strategy_class); |
|
116 | 116 | } |
117 | 117 | $display_strategy = new $display_strategy_class(); |
118 | - if ( ! $display_strategy instanceof ProgressStepsDisplayInterface ) { |
|
118 | + if ( ! $display_strategy instanceof ProgressStepsDisplayInterface) { |
|
119 | 119 | throw new InvalidClassException( |
120 | 120 | $display_strategy_class, |
121 | 121 | sprintf( |
122 | - __( 'The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso' ), |
|
122 | + __('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'), |
|
123 | 123 | $display_strategy_class, |
124 | 124 | '\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface' |
125 | 125 | ) |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | * @param string $default_step |
135 | 135 | * @throws InvalidDataTypeException |
136 | 136 | */ |
137 | - public function setDefaultStep( $default_step ) { |
|
138 | - if ( ! is_string( $default_step ) ) { |
|
139 | - throw new InvalidDataTypeException( '$default_step', $default_step, 'string' ); |
|
137 | + public function setDefaultStep($default_step) { |
|
138 | + if ( ! is_string($default_step)) { |
|
139 | + throw new InvalidDataTypeException('$default_step', $default_step, 'string'); |
|
140 | 140 | } |
141 | 141 | $this->default_step = $default_step; |
142 | 142 | } |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * @param string $form_step_url_key |
148 | 148 | * @throws InvalidDataTypeException |
149 | 149 | */ |
150 | - public function setFormStepUrlKey( $form_step_url_key = 'ee-form-step' ) { |
|
151 | - if ( ! is_string( $form_step_url_key ) ) { |
|
152 | - throw new InvalidDataTypeException( '$form_step_key', $form_step_url_key, 'string' ); |
|
150 | + public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') { |
|
151 | + if ( ! is_string($form_step_url_key)) { |
|
152 | + throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string'); |
|
153 | 153 | } |
154 | - $this->form_step_url_key = ! empty( $form_step_url_key ) ? $form_step_url_key : 'ee-form-step'; |
|
154 | + $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -160,26 +160,26 @@ discard block |
||
160 | 160 | * @param string $step |
161 | 161 | * @throws InvalidIdentifierException |
162 | 162 | */ |
163 | - public function setCurrentStep( $step = '' ) { |
|
163 | + public function setCurrentStep($step = '') { |
|
164 | 164 | // use incoming value if it's set, otherwise use request param if it's set, otherwise use default |
165 | - $step = ! empty( $step ) |
|
165 | + $step = ! empty($step) |
|
166 | 166 | ? $step |
167 | - : $this->request->get( $this->form_step_url_key, $this->default_step ); |
|
167 | + : $this->request->get($this->form_step_url_key, $this->default_step); |
|
168 | 168 | // grab the step previously known as current, in case we need to revert |
169 | 169 | $current_current_step = $this->collection->current(); |
170 | 170 | // verify that requested step exists |
171 | - if ( ! $this->collection->has( $step ) ) { |
|
172 | - throw new InvalidIdentifierException( $step, $this->default_step ); |
|
171 | + if ( ! $this->collection->has($step)) { |
|
172 | + throw new InvalidIdentifierException($step, $this->default_step); |
|
173 | 173 | } |
174 | - if ( $this->collection->setCurrent( $step ) ) { |
|
174 | + if ($this->collection->setCurrent($step)) { |
|
175 | 175 | // if the old boss is the same as the new boss, then nothing changes |
176 | - if ( $this->collection->current() !== $current_current_step ) { |
|
177 | - $current_current_step->setIsCurrent( false ); |
|
176 | + if ($this->collection->current() !== $current_current_step) { |
|
177 | + $current_current_step->setIsCurrent(false); |
|
178 | 178 | } |
179 | 179 | $this->collection->current()->setIsCurrent(); |
180 | 180 | } else { |
181 | - $this->collection->setCurrent( $current_current_step->id() ); |
|
182 | - $current_current_step->setIsCurrent( true ); |
|
181 | + $this->collection->setCurrent($current_current_step->id()); |
|
182 | + $current_current_step->setIsCurrent(true); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | public function setPreviousStepsCompleted() { |
192 | 192 | $current_current_step = $this->collection->current(); |
193 | 193 | $this->collection->rewind(); |
194 | - while ( $this->collection->valid() ) { |
|
195 | - if ( $this->collection->current() === $current_current_step ) { |
|
194 | + while ($this->collection->valid()) { |
|
195 | + if ($this->collection->current() === $current_current_step) { |
|
196 | 196 | break; |
197 | 197 | } |
198 | 198 | $this->setCurrentStepCompleted(); |
199 | 199 | $this->collection->next(); |
200 | 200 | } |
201 | - $this->collection->setCurrentUsingObject( $current_current_step ); |
|
201 | + $this->collection->setCurrentUsingObject($current_current_step); |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | public function displaySteps() { |
240 | 240 | return \EEH_Template::display_template( |
241 | 241 | $this->display_strategy->getTemplate(), |
242 | - array( 'progress_steps' => $this->collection ), |
|
242 | + array('progress_steps' => $this->collection), |
|
243 | 243 | true |
244 | 244 | ); |
245 | 245 | } |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @param bool $completed |
251 | 251 | * @return \EventEspresso\core\services\progress_steps\ProgressStepInterface |
252 | 252 | */ |
253 | - public function setCurrentStepCompleted( $completed = true ) { |
|
254 | - return $this->collection->current()->setIsCompleted( $completed ); |
|
253 | + public function setCurrentStepCompleted($completed = true) { |
|
254 | + return $this->collection->current()->setIsCompleted($completed); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 |
@@ -2,10 +2,10 @@ |
||
2 | 2 | namespace EventEspresso\core\services\progress_steps; |
3 | 3 | |
4 | 4 | use EE_Request; |
5 | -use EventEspresso\core\exceptions\InvalidClassException; |
|
6 | -use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
7 | -use EventEspresso\core\exceptions\InvalidIdentifierException; |
|
8 | -use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
5 | +use EventEspresso\core\exceptions\InvalidClassException; |
|
6 | +use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
7 | +use EventEspresso\core\exceptions\InvalidIdentifierException; |
|
8 | +use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
9 | 9 | use EventEspresso\core\services\collections\Collection; |
10 | 10 | use EventEspresso\core\services\collections\CollectionInterface; |
11 | 11 | use EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface; |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css |
30 | 30 | wp_enqueue_style( |
31 | 31 | 'ee_progress_steps_display_number_bubbles', |
32 | - plugin_dir_url( __FILE__ ) . 'number_bubbles.css' |
|
32 | + plugin_dir_url(__FILE__).'number_bubbles.css' |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function getTemplate() { |
44 | 44 | // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php'; |
45 | - return __DIR__ . DS .'number_bubbles.template.php'; |
|
45 | + return __DIR__.DS.'number_bubbles.template.php'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | } |
@@ -1,6 +1,6 @@ |
||
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 | * Class EE_Line_Item_Filter_Collection |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param int $code |
26 | 26 | * @param \Exception $previous |
27 | 27 | */ |
28 | - public function __construct( $command_name, $message = '', $code = 0, \Exception $previous = null ) { |
|
29 | - if ( empty( $message ) ) { |
|
28 | + public function __construct($command_name, $message = '', $code = 0, \Exception $previous = null) { |
|
29 | + if (empty($message)) { |
|
30 | 30 | $message = sprintf( |
31 | - __( 'The supplied Command Handler "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', 'event_espresso' ), |
|
31 | + __('The supplied Command Handler "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', 'event_espresso'), |
|
32 | 32 | $command_name |
33 | 33 | ); |
34 | 34 | } |
35 | - parent::__construct( $message, $code, $previous ); |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param \EventEspresso\core\services\commands\CommandInterface $command |
20 | 20 | * @return mixed |
21 | 21 | */ |
22 | - public function handle( CommandInterface $command ); |
|
22 | + public function handle(CommandInterface $command); |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | // End of file CommandHandlerInterface.php |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | * @param \EventEspresso\core\services\commands\CommandHandlerInterface $command_handler |
20 | 20 | * @return mixed |
21 | 21 | */ |
22 | - public function addCommandHandler( CommandHandlerInterface $command_handler ); |
|
22 | + public function addCommandHandler(CommandHandlerInterface $command_handler); |
|
23 | 23 | |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @param \EventEspresso\core\services\commands\CommandInterface $command |
27 | 27 | * @return mixed |
28 | 28 | */ |
29 | - public function getCommandHandler( CommandInterface $command ); |
|
29 | + public function getCommandHandler(CommandInterface $command); |
|
30 | 30 | |
31 | 31 | } |
32 | 32 | // End of file CommandHandlerManagerInterface.php |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * just checks the field isn't blank |
27 | 27 | * |
28 | 28 | * @param $normalized_value |
29 | - * @return bool |
|
29 | + * @return boolean|null |
|
30 | 30 | * @throws \EE_Validation_Error |
31 | 31 | */ |
32 | 32 | function validate($normalized_value) { |
@@ -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 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param \EE_Request $request |
76 | 76 | * @param \EE_Response $response |
77 | 77 | */ |
78 | - protected function __construct( EE_Request $request, EE_Response $response ) { |
|
78 | + protected function __construct(EE_Request $request, EE_Response $response) { |
|
79 | 79 | $this->_request = $request; |
80 | 80 | $this->_response = $response; |
81 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
82 | - do_action( 'EE_Dependency_Map____construct' ); |
|
81 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
82 | + do_action('EE_Dependency_Map____construct'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | * @param \EE_Response $response |
102 | 102 | * @return \EE_Dependency_Map instance |
103 | 103 | */ |
104 | - public static function instance( EE_Request $request = null, EE_Response $response = null ) { |
|
104 | + public static function instance(EE_Request $request = null, EE_Response $response = null) { |
|
105 | 105 | // check if class object is instantiated, and instantiated properly |
106 | - if ( ! self::$_instance instanceof EE_Dependency_Map ) { |
|
107 | - self::$_instance = new EE_Dependency_Map( $request, $response ); |
|
106 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
107 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
108 | 108 | } |
109 | 109 | return self::$_instance; |
110 | 110 | } |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | * @param array $dependencies |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - public static function register_dependencies( $class, $dependencies ) { |
|
120 | - if ( ! isset( self::$_instance->_dependency_map[ $class ] ) ) { |
|
119 | + public static function register_dependencies($class, $dependencies) { |
|
120 | + if ( ! isset(self::$_instance->_dependency_map[$class])) { |
|
121 | 121 | // we need to make sure that any aliases used when registering a dependency |
122 | 122 | // get resolved to the correct class name |
123 | - foreach ( (array) $dependencies as $dependency => $load_source ) { |
|
124 | - $alias = self::$_instance->get_alias( $dependency ); |
|
125 | - unset( $dependencies[ $dependency ] ); |
|
126 | - $dependencies[ $alias ] = $load_source; |
|
123 | + foreach ((array) $dependencies as $dependency => $load_source) { |
|
124 | + $alias = self::$_instance->get_alias($dependency); |
|
125 | + unset($dependencies[$dependency]); |
|
126 | + $dependencies[$alias] = $load_source; |
|
127 | 127 | } |
128 | - self::$_instance->_dependency_map[ $class ] = (array) $dependencies; |
|
128 | + self::$_instance->_dependency_map[$class] = (array) $dependencies; |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | return false; |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | * @return bool |
140 | 140 | * @throws \EE_Error |
141 | 141 | */ |
142 | - public static function register_class_loader( $class_name, $loader = 'load_core' ) { |
|
142 | + public static function register_class_loader($class_name, $loader = 'load_core') { |
|
143 | 143 | // check that loader method starts with "load_" and exists in EE_Registry |
144 | - if ( strpos( $loader, 'load_' ) !== 0 || ! method_exists( 'EE_Registry', $loader ) ) { |
|
144 | + if (strpos($loader, 'load_') !== 0 || ! method_exists('EE_Registry', $loader)) { |
|
145 | 145 | throw new EE_Error( |
146 | 146 | sprintf( |
147 | - __( '"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso' ), |
|
147 | + __('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'), |
|
148 | 148 | $loader |
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | } |
152 | - $class_name = self::$_instance->get_alias( $class_name ); |
|
153 | - if ( ! isset( self::$_instance->_class_loaders[ $class_name ] ) ) { |
|
154 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
152 | + $class_name = self::$_instance->get_alias($class_name); |
|
153 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
154 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
155 | 155 | return true; |
156 | 156 | } |
157 | 157 | return false; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @param string $class_name |
175 | 175 | * @return boolean |
176 | 176 | */ |
177 | - public function has( $class_name = '' ) { |
|
178 | - return isset( $this->_dependency_map[ $class_name ] ) ? true : false; |
|
177 | + public function has($class_name = '') { |
|
178 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @param string $dependency |
188 | 188 | * @return bool |
189 | 189 | */ |
190 | - public function has_dependency_for_class( $class_name = '', $dependency = '' ) { |
|
191 | - $dependency = $this->get_alias( $dependency ); |
|
192 | - return isset( $this->_dependency_map[ $class_name ], $this->_dependency_map[ $class_name ][ $dependency ] ) |
|
190 | + public function has_dependency_for_class($class_name = '', $dependency = '') { |
|
191 | + $dependency = $this->get_alias($dependency); |
|
192 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
193 | 193 | ? true |
194 | 194 | : false; |
195 | 195 | } |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | * @param string $dependency |
204 | 204 | * @return int |
205 | 205 | */ |
206 | - public function loading_strategy_for_class_dependency( $class_name = '', $dependency = '' ) { |
|
207 | - $dependency = $this->get_alias( $dependency ); |
|
208 | - return $this->has_dependency_for_class( $class_name, $dependency ) |
|
209 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
206 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') { |
|
207 | + $dependency = $this->get_alias($dependency); |
|
208 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
209 | + ? $this->_dependency_map[$class_name][$dependency] |
|
210 | 210 | : EE_Dependency_Map::not_registered; |
211 | 211 | } |
212 | 212 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @param string $class_name |
217 | 217 | * @return string | Closure |
218 | 218 | */ |
219 | - public function class_loader( $class_name ) { |
|
220 | - $class_name = $this->get_alias( $class_name ); |
|
221 | - return isset( $this->_class_loaders[ $class_name ] ) ? $this->_class_loaders[ $class_name ] : ''; |
|
219 | + public function class_loader($class_name) { |
|
220 | + $class_name = $this->get_alias($class_name); |
|
221 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @param string $alias |
240 | 240 | * @return bool |
241 | 241 | */ |
242 | - public function add_alias( $class_name, $alias ) { |
|
243 | - $this->_aliases[ $class_name ] = $alias; |
|
242 | + public function add_alias($class_name, $alias) { |
|
243 | + $this->_aliases[$class_name] = $alias; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * @param string $class_name |
252 | 252 | * @return boolean |
253 | 253 | */ |
254 | - public function has_alias( $class_name = '' ) { |
|
255 | - return isset( $this->_aliases[ $class_name ] ) ? true : false; |
|
254 | + public function has_alias($class_name = '') { |
|
255 | + return isset($this->_aliases[$class_name]) ? true : false; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | * @param string $class_name |
273 | 273 | * @return boolean |
274 | 274 | */ |
275 | - public function get_alias( $class_name = '' ) { |
|
276 | - return $this->has_alias( $class_name ) |
|
277 | - ? $this->get_alias( $this->_aliases[ $class_name ] ) |
|
275 | + public function get_alias($class_name = '') { |
|
276 | + return $this->has_alias($class_name) |
|
277 | + ? $this->get_alias($this->_aliases[$class_name]) |
|
278 | 278 | : $class_name; |
279 | 279 | } |
280 | 280 | |
@@ -461,17 +461,17 @@ discard block |
||
461 | 461 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
462 | 462 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
463 | 463 | 'EE_Messages_Generator' => function() { |
464 | - return EE_Registry::instance()->load_lib( 'Messages_Generator', array(), false, false ); |
|
464 | + return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false); |
|
465 | 465 | }, |
466 | - 'EE_Messages_Template_Defaults' => function( $arguments = array() ) { |
|
467 | - return EE_Registry::instance()->load_lib( 'Messages_Template_Defaults', $arguments, false, false ); |
|
466 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
467 | + return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false); |
|
468 | 468 | }, |
469 | 469 | //load_model |
470 | 470 | 'EEM_Message_Template_Group' => 'load_model', |
471 | 471 | 'EEM_Message_Template' => 'load_model', |
472 | 472 | //load_helper |
473 | 473 | 'EEH_Parse_Shortcodes' => function() { |
474 | - if ( EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ) ) { |
|
474 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
475 | 475 | return new EEH_Parse_Shortcodes(); |
476 | 476 | } |
477 | 477 | return null; |
@@ -968,7 +968,7 @@ |
||
968 | 968 | $dependency = null; |
969 | 969 | // should dependency be loaded from cache ? |
970 | 970 | $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( $class_name, $param_class ) |
971 | - !== EE_Dependency_Map::load_new_object |
|
971 | + !== EE_Dependency_Map::load_new_object |
|
972 | 972 | ? true |
973 | 973 | : false; |
974 | 974 | // we might have a dependency... |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @param \EE_Dependency_Map $dependency_map |
185 | 185 | * @return \EE_Registry instance |
186 | 186 | */ |
187 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
187 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
188 | 188 | // check if class object is instantiated |
189 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
190 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
189 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
190 | + self::$_instance = new EE_Registry($dependency_map); |
|
191 | 191 | } |
192 | 192 | return self::$_instance; |
193 | 193 | } |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | * @param \EE_Dependency_Map $dependency_map |
203 | 203 | * @return \EE_Registry |
204 | 204 | */ |
205 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
205 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
206 | 206 | $this->_dependency_map = $dependency_map; |
207 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
207 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | $this->modules = new stdClass(); |
233 | 233 | $this->shortcodes = new stdClass(); |
234 | 234 | $this->widgets = new stdClass(); |
235 | - $this->load_core( 'Base', array(), true ); |
|
235 | + $this->load_core('Base', array(), true); |
|
236 | 236 | // add our request and response objects to the cache |
237 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
237 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
238 | 238 | $this->_set_cached_class( |
239 | 239 | $request_loader(), |
240 | 240 | 'EE_Request' |
241 | 241 | ); |
242 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
242 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
243 | 243 | $this->_set_cached_class( |
244 | 244 | $response_loader(), |
245 | 245 | 'EE_Response' |
246 | 246 | ); |
247 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
247 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function init() { |
259 | 259 | // Get current page protocol |
260 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
260 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
261 | 261 | // Output admin-ajax.php URL with same protocol as current page |
262 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
263 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
262 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
263 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | * @return string |
272 | 272 | */ |
273 | 273 | public static function localize_i18n_js_strings() { |
274 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
275 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
276 | - if ( is_scalar( $value ) ) { |
|
277 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
274 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
275 | + foreach ($i18n_js_strings as $key => $value) { |
|
276 | + if (is_scalar($value)) { |
|
277 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
281 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * @param mixed string | EED_Module $module |
288 | 288 | */ |
289 | - public function add_module( $module ) { |
|
290 | - if ( $module instanceof EED_Module ) { |
|
291 | - $module_class = get_class( $module ); |
|
289 | + public function add_module($module) { |
|
290 | + if ($module instanceof EED_Module) { |
|
291 | + $module_class = get_class($module); |
|
292 | 292 | $this->modules->{$module_class} = $module; |
293 | 293 | } else { |
294 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
295 | - $this->load_core( 'Module_Request_Router' ); |
|
294 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
295 | + $this->load_core('Module_Request_Router'); |
|
296 | 296 | } |
297 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
297 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | * @param string $module_name |
305 | 305 | * @return mixed EED_Module | NULL |
306 | 306 | */ |
307 | - public function get_module( $module_name = '' ) { |
|
308 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
307 | + public function get_module($module_name = '') { |
|
308 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -319,20 +319,20 @@ discard block |
||
319 | 319 | * @param bool $load_only |
320 | 320 | * @return mixed |
321 | 321 | */ |
322 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
322 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
323 | 323 | $core_paths = apply_filters( |
324 | 324 | 'FHEE__EE_Registry__load_core__core_paths', |
325 | 325 | array( |
326 | 326 | EE_CORE, |
327 | 327 | EE_ADMIN, |
328 | 328 | EE_CPTS, |
329 | - EE_CORE . 'data_migration_scripts' . DS, |
|
330 | - EE_CORE . 'request_stack' . DS, |
|
331 | - EE_CORE . 'middleware' . DS, |
|
329 | + EE_CORE.'data_migration_scripts'.DS, |
|
330 | + EE_CORE.'request_stack'.DS, |
|
331 | + EE_CORE.'middleware'.DS, |
|
332 | 332 | ) |
333 | 333 | ); |
334 | 334 | // retrieve instantiated class |
335 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
335 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | * @param bool $load_only |
347 | 347 | * @return mixed |
348 | 348 | */ |
349 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
349 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
350 | 350 | $service_paths = apply_filters( |
351 | 351 | 'FHEE__EE_Registry__load_service__service_paths', |
352 | 352 | array( |
353 | - EE_CORE . 'services' . DS, |
|
353 | + EE_CORE.'services'.DS, |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | // retrieve instantiated class |
357 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
357 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @param mixed $arguments |
368 | 368 | * @return EE_Data_Migration_Script_Base |
369 | 369 | */ |
370 | - public function load_dms( $class_name, $arguments = array() ) { |
|
370 | + public function load_dms($class_name, $arguments = array()) { |
|
371 | 371 | // retrieve instantiated class |
372 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
372 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
385 | 385 | * @return EE_Base_Class | bool |
386 | 386 | */ |
387 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
388 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
387 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
388 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
389 | 389 | EE_CORE, |
390 | 390 | EE_CLASSES, |
391 | 391 | EE_BUSINESS |
392 | - ) ); |
|
392 | + )); |
|
393 | 393 | // retrieve instantiated class |
394 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
394 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | * @param bool $load_only |
405 | 405 | * @return EEH_Base | bool |
406 | 406 | */ |
407 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
407 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
408 | 408 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
409 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
409 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
410 | 410 | // retrieve instantiated class |
411 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
411 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -423,16 +423,16 @@ discard block |
||
423 | 423 | * @param bool $cache whether to cache the object or not. |
424 | 424 | * @return mixed |
425 | 425 | */ |
426 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
426 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
427 | 427 | $paths = array( |
428 | 428 | EE_LIBRARIES, |
429 | - EE_LIBRARIES . 'messages' . DS, |
|
430 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
431 | - EE_LIBRARIES . 'qtips' . DS, |
|
432 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
429 | + EE_LIBRARIES.'messages'.DS, |
|
430 | + EE_LIBRARIES.'shortcodes'.DS, |
|
431 | + EE_LIBRARIES.'qtips'.DS, |
|
432 | + EE_LIBRARIES.'payment_methods'.DS, |
|
433 | 433 | ); |
434 | 434 | // retrieve instantiated class |
435 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
435 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | * @param bool $load_only |
446 | 446 | * @return EEM_Base | bool |
447 | 447 | */ |
448 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
449 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
448 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
449 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
450 | 450 | EE_MODELS, |
451 | 451 | EE_CORE |
452 | - ) ); |
|
452 | + )); |
|
453 | 453 | // retrieve instantiated class |
454 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
454 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | * @param bool $load_only |
465 | 465 | * @return mixed | bool |
466 | 466 | */ |
467 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
467 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
468 | 468 | $paths = array( |
469 | - EE_MODELS . 'fields' . DS, |
|
470 | - EE_MODELS . 'helpers' . DS, |
|
471 | - EE_MODELS . 'relations' . DS, |
|
472 | - EE_MODELS . 'strategies' . DS |
|
469 | + EE_MODELS.'fields'.DS, |
|
470 | + EE_MODELS.'helpers'.DS, |
|
471 | + EE_MODELS.'relations'.DS, |
|
472 | + EE_MODELS.'strategies'.DS |
|
473 | 473 | ); |
474 | 474 | // retrieve instantiated class |
475 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
475 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
483 | 483 | * @return boolean |
484 | 484 | */ |
485 | - public function is_model_name( $model_name ) { |
|
486 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
485 | + public function is_model_name($model_name) { |
|
486 | + return isset($this->models[$model_name]) ? true : false; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * @param bool $load_only |
499 | 499 | * @return mixed |
500 | 500 | */ |
501 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
501 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
502 | 502 | // retrieve instantiated class |
503 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
503 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | * @param bool $load_only |
516 | 516 | * @return EE_Addon |
517 | 517 | */ |
518 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
518 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
519 | 519 | // retrieve instantiated class |
520 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
520 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -548,35 +548,35 @@ discard block |
||
548 | 548 | $load_only = false, |
549 | 549 | $addon = false |
550 | 550 | ) { |
551 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
552 | - if ( ! class_exists( $class_name ) ) { |
|
551 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
552 | + if ( ! class_exists($class_name)) { |
|
553 | 553 | // maybe the class is registered with a preceding \ |
554 | - $class_name = strpos( $class_name, '\\' ) !== 0 ? '\\' . $class_name : $class_name; |
|
554 | + $class_name = strpos($class_name, '\\') !== 0 ? '\\'.$class_name : $class_name; |
|
555 | 555 | // still doesn't exist ? |
556 | - if ( ! class_exists( $class_name ) ) { |
|
556 | + if ( ! class_exists($class_name)) { |
|
557 | 557 | return null; |
558 | 558 | } |
559 | 559 | } |
560 | 560 | // if we're only loading the class and it already exists, then let's just return true immediately |
561 | - if ( $load_only ) { |
|
561 | + if ($load_only) { |
|
562 | 562 | return true; |
563 | 563 | } |
564 | 564 | $addon = $addon ? 'addon' : ''; |
565 | 565 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
566 | 566 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
567 | 567 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
568 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
568 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
569 | 569 | // return object if it's already cached |
570 | - $cached_class = $this->_get_cached_class( $class_name, $addon ); |
|
571 | - if ( $cached_class !== null ) { |
|
570 | + $cached_class = $this->_get_cached_class($class_name, $addon); |
|
571 | + if ($cached_class !== null) { |
|
572 | 572 | return $cached_class; |
573 | 573 | } |
574 | 574 | } |
575 | 575 | // instantiate the requested object |
576 | - $class_obj = $this->_create_object( $class_name, $arguments, $addon, $from_db ); |
|
577 | - if ( $this->_cache_on && $cache ) { |
|
576 | + $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db); |
|
577 | + if ($this->_cache_on && $cache) { |
|
578 | 578 | // save it for later... kinda like gum { : $ |
579 | - $this->_set_cached_class( $class_obj, $class_name, $addon, $from_db ); |
|
579 | + $this->_set_cached_class($class_obj, $class_name, $addon, $from_db); |
|
580 | 580 | } |
581 | 581 | $this->_cache_on = true; |
582 | 582 | return $class_obj; |
@@ -611,47 +611,47 @@ discard block |
||
611 | 611 | $load_only = false |
612 | 612 | ) { |
613 | 613 | // strip php file extension |
614 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
614 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
615 | 615 | // does the class have a prefix ? |
616 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
616 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
617 | 617 | // make sure $class_prefix is uppercase |
618 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
618 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
619 | 619 | // add class prefix ONCE!!! |
620 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
620 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
621 | 621 | } |
622 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
623 | - $class_exists = class_exists( $class_name ); |
|
622 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
623 | + $class_exists = class_exists($class_name); |
|
624 | 624 | // if we're only loading the class and it already exists, then let's just return true immediately |
625 | - if ( $load_only && $class_exists ) { |
|
625 | + if ($load_only && $class_exists) { |
|
626 | 626 | return true; |
627 | 627 | } |
628 | 628 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
629 | 629 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
630 | 630 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
631 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
631 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
632 | 632 | // return object if it's already cached |
633 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
634 | - if ( $cached_class !== null ) { |
|
633 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
634 | + if ($cached_class !== null) { |
|
635 | 635 | return $cached_class; |
636 | 636 | } |
637 | 637 | } |
638 | 638 | // if the class doesn't already exist.. then we need to try and find the file and load it |
639 | - if ( ! $class_exists ) { |
|
639 | + if ( ! $class_exists) { |
|
640 | 640 | // get full path to file |
641 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
641 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
642 | 642 | // load the file |
643 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
643 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
644 | 644 | // if loading failed, or we are only loading a file but NOT instantiating an object |
645 | - if ( ! $loaded || $load_only ) { |
|
645 | + if ( ! $loaded || $load_only) { |
|
646 | 646 | // return boolean if only loading, or null if an object was expected |
647 | 647 | return $load_only ? $loaded : null; |
648 | 648 | } |
649 | 649 | } |
650 | 650 | // instantiate the requested object |
651 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
652 | - if ( $this->_cache_on && $cache ) { |
|
651 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
652 | + if ($this->_cache_on && $cache) { |
|
653 | 653 | // save it for later... kinda like gum { : $ |
654 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
654 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
655 | 655 | } |
656 | 656 | $this->_cache_on = true; |
657 | 657 | return $class_obj; |
@@ -674,21 +674,21 @@ discard block |
||
674 | 674 | * @param string $class_prefix |
675 | 675 | * @return null|object |
676 | 676 | */ |
677 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
678 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
679 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
677 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
678 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
679 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
680 | 680 | } else { |
681 | 681 | // have to specify something, but not anything that will conflict |
682 | 682 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
683 | 683 | } |
684 | 684 | // check if class has already been loaded, and return it if it has been |
685 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
685 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
686 | 686 | return $this->{$class_abbreviation}; |
687 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
687 | + } else if (isset ($this->{$class_name} )) { |
|
688 | 688 | return $this->{$class_name}; |
689 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
689 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
690 | 690 | return $this->LIB->{$class_name}; |
691 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
691 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
692 | 692 | return $this->addons->{$class_name}; |
693 | 693 | } |
694 | 694 | return null; |
@@ -709,20 +709,20 @@ discard block |
||
709 | 709 | * @param array $file_paths |
710 | 710 | * @return string | bool |
711 | 711 | */ |
712 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
712 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
713 | 713 | // make sure $file_paths is an array |
714 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
714 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
715 | 715 | // cycle thru paths |
716 | - foreach ( $file_paths as $key => $file_path ) { |
|
716 | + foreach ($file_paths as $key => $file_path) { |
|
717 | 717 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
718 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
718 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
719 | 719 | // prep file type |
720 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
720 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
721 | 721 | // build full file path |
722 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
722 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
723 | 723 | //does the file exist and can be read ? |
724 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
725 | - return $file_paths[ $key ]; |
|
724 | + if (is_readable($file_paths[$key])) { |
|
725 | + return $file_paths[$key]; |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | return false; |
@@ -744,29 +744,29 @@ discard block |
||
744 | 744 | * @return boolean |
745 | 745 | * @throws \EE_Error |
746 | 746 | */ |
747 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
747 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
748 | 748 | // don't give up! you gotta... |
749 | 749 | try { |
750 | 750 | //does the file exist and can it be read ? |
751 | - if ( ! $path ) { |
|
751 | + if ( ! $path) { |
|
752 | 752 | // so sorry, can't find the file |
753 | - throw new EE_Error ( |
|
753 | + throw new EE_Error( |
|
754 | 754 | sprintf( |
755 | - __( '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' ), |
|
756 | - trim( $type, '.' ), |
|
755 | + __('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'), |
|
756 | + trim($type, '.'), |
|
757 | 757 | $class_name, |
758 | - '<br />' . implode( ',<br />', $file_paths ) |
|
758 | + '<br />'.implode(',<br />', $file_paths) |
|
759 | 759 | ) |
760 | 760 | ); |
761 | 761 | } |
762 | 762 | // get the file |
763 | - require_once( $path ); |
|
763 | + require_once($path); |
|
764 | 764 | // if the class isn't already declared somewhere |
765 | - if ( class_exists( $class_name, false ) === false ) { |
|
765 | + if (class_exists($class_name, false) === false) { |
|
766 | 766 | // so sorry, not a class |
767 | 767 | throw new EE_Error( |
768 | 768 | sprintf( |
769 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
769 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
770 | 770 | $type, |
771 | 771 | $path, |
772 | 772 | $class_name |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | ); |
775 | 775 | } |
776 | 776 | |
777 | - } catch ( EE_Error $e ) { |
|
777 | + } catch (EE_Error $e) { |
|
778 | 778 | $e->get_error(); |
779 | 779 | return false; |
780 | 780 | } |
@@ -806,61 +806,61 @@ discard block |
||
806 | 806 | * @return null | object |
807 | 807 | * @throws \EE_Error |
808 | 808 | */ |
809 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
809 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
810 | 810 | $class_obj = null; |
811 | 811 | $instantiation_mode = '0) none'; |
812 | 812 | // don't give up! you gotta... |
813 | 813 | try { |
814 | 814 | // create reflection |
815 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
815 | + $reflector = $this->get_ReflectionClass($class_name); |
|
816 | 816 | // make sure arguments are an array |
817 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
817 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
818 | 818 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
819 | 819 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
820 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
820 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
821 | 821 | ? $arguments |
822 | - : array( $arguments ); |
|
822 | + : array($arguments); |
|
823 | 823 | // attempt to inject dependencies ? |
824 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
825 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
824 | + if ($this->_dependency_map->has($class_name)) { |
|
825 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
826 | 826 | } |
827 | 827 | // instantiate the class if possible |
828 | - if ( $reflector->isAbstract() ) { |
|
828 | + if ($reflector->isAbstract()) { |
|
829 | 829 | // nothing to instantiate, loading file was enough |
830 | 830 | // does not throw an exception so $instantiation_mode is unused |
831 | 831 | // $instantiation_mode = "1) no constructor abstract class"; |
832 | 832 | $class_obj = true; |
833 | - } else if ( $reflector->getConstructor() === null && $reflector->isInstantiable() && empty( $arguments ) ) { |
|
833 | + } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) { |
|
834 | 834 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
835 | 835 | $instantiation_mode = "2) no constructor but instantiable"; |
836 | 836 | $class_obj = $reflector->newInstance(); |
837 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
837 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
838 | 838 | $instantiation_mode = "3) new_instance_from_db()"; |
839 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
840 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
839 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
840 | + } else if (method_exists($class_name, 'new_instance')) { |
|
841 | 841 | $instantiation_mode = "4) new_instance()"; |
842 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
843 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
842 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
843 | + } else if (method_exists($class_name, 'instance')) { |
|
844 | 844 | $instantiation_mode = "5) instance()"; |
845 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
846 | - } else if ( $reflector->isInstantiable() ) { |
|
845 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
846 | + } else if ($reflector->isInstantiable()) { |
|
847 | 847 | $instantiation_mode = "6) constructor"; |
848 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
848 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
849 | 849 | } else { |
850 | 850 | // heh ? something's not right ! |
851 | 851 | throw new EE_Error( |
852 | 852 | sprintf( |
853 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
853 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
854 | 854 | $type, |
855 | 855 | $class_name |
856 | 856 | ) |
857 | 857 | ); |
858 | 858 | } |
859 | - } catch ( Exception $e ) { |
|
860 | - if ( ! $e instanceof EE_Error ) { |
|
859 | + } catch (Exception $e) { |
|
860 | + if ( ! $e instanceof EE_Error) { |
|
861 | 861 | $e = new EE_Error( |
862 | 862 | sprintf( |
863 | - __( 'The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso' ), |
|
863 | + __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'), |
|
864 | 864 | $class_name, |
865 | 865 | '<br />', |
866 | 866 | $e->getMessage(), |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @param array $array |
881 | 881 | * @return bool |
882 | 882 | */ |
883 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
884 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
883 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
884 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -896,14 +896,14 @@ discard block |
||
896 | 896 | * @param string $class_name |
897 | 897 | * @return ReflectionClass |
898 | 898 | */ |
899 | - public function get_ReflectionClass( $class_name ) { |
|
899 | + public function get_ReflectionClass($class_name) { |
|
900 | 900 | if ( |
901 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
902 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
901 | + ! isset($this->_reflectors[$class_name]) |
|
902 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
903 | 903 | ) { |
904 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
904 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
905 | 905 | } |
906 | - return $this->_reflectors[ $class_name ]; |
|
906 | + return $this->_reflectors[$class_name]; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | |
@@ -928,50 +928,50 @@ discard block |
||
928 | 928 | * @return array |
929 | 929 | * @throws \ReflectionException |
930 | 930 | */ |
931 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
931 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
932 | 932 | // let's examine the constructor |
933 | 933 | $constructor = $reflector->getConstructor(); |
934 | 934 | // whu? huh? nothing? |
935 | - if ( ! $constructor ) { |
|
935 | + if ( ! $constructor) { |
|
936 | 936 | return $arguments; |
937 | 937 | } |
938 | 938 | // get constructor parameters |
939 | 939 | $params = $constructor->getParameters(); |
940 | 940 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
941 | - $argument_keys = array_keys( $arguments ); |
|
941 | + $argument_keys = array_keys($arguments); |
|
942 | 942 | // now loop thru all of the constructors expected parameters |
943 | - foreach ( $params as $index => $param ) { |
|
943 | + foreach ($params as $index => $param) { |
|
944 | 944 | // is this a dependency for a specific class ? |
945 | 945 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
946 | 946 | if ( |
947 | 947 | // param is not even a class |
948 | - empty( $param_class ) |
|
948 | + empty($param_class) |
|
949 | 949 | // and something already exists in the incoming arguments for this param |
950 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
950 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
951 | 951 | ) { |
952 | 952 | // so let's skip this argument and move on to the next |
953 | 953 | continue; |
954 | 954 | } else if ( |
955 | 955 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
956 | - ! empty( $param_class ) |
|
957 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
958 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
956 | + ! empty($param_class) |
|
957 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
958 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
959 | 959 | ) { |
960 | 960 | // skip this argument and move on to the next |
961 | 961 | continue; |
962 | 962 | } else if ( |
963 | 963 | // parameter is type hinted as a class, and should be injected |
964 | - ! empty( $param_class ) |
|
965 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
964 | + ! empty($param_class) |
|
965 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
966 | 966 | ) { |
967 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
967 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
968 | 968 | } else { |
969 | 969 | try { |
970 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
971 | - } catch ( ReflectionException $e ) { |
|
970 | + $arguments[$index] = $param->getDefaultValue(); |
|
971 | + } catch (ReflectionException $e) { |
|
972 | 972 | throw new ReflectionException( |
973 | 973 | sprintf( |
974 | - __( '%1$s for parameter "$%2$s"', 'event_espresso' ), |
|
974 | + __('%1$s for parameter "$%2$s"', 'event_espresso'), |
|
975 | 975 | $e->getMessage(), |
976 | 976 | $param->getName() |
977 | 977 | ) |
@@ -993,30 +993,30 @@ discard block |
||
993 | 993 | * @param mixed $index |
994 | 994 | * @return array |
995 | 995 | */ |
996 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
996 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
997 | 997 | $dependency = null; |
998 | 998 | // should dependency be loaded from cache ? |
999 | - $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( $class_name, $param_class ) |
|
999 | + $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class) |
|
1000 | 1000 | !== EE_Dependency_Map::load_new_object |
1001 | 1001 | ? true |
1002 | 1002 | : false; |
1003 | 1003 | // we might have a dependency... |
1004 | 1004 | // let's MAYBE try and find it in our cache if that's what's been requested |
1005 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
1005 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
1006 | 1006 | // and grab it if it exists |
1007 | - if ( $cached_class instanceof $param_class ) { |
|
1007 | + if ($cached_class instanceof $param_class) { |
|
1008 | 1008 | $dependency = $cached_class; |
1009 | - } else if ( $param_class != $class_name ) { |
|
1009 | + } else if ($param_class != $class_name) { |
|
1010 | 1010 | // obtain the loader method from the dependency map |
1011 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
1011 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
1012 | 1012 | // is loader a custom closure ? |
1013 | - if ( $loader instanceof Closure ) { |
|
1013 | + if ($loader instanceof Closure) { |
|
1014 | 1014 | $dependency = $loader(); |
1015 | 1015 | } else { |
1016 | 1016 | // set the cache on property for the recursive loading call |
1017 | 1017 | $this->_cache_on = $cache_on; |
1018 | 1018 | // if not, then let's try and load it via the registry |
1019 | - if ( method_exists( $this, $loader ) ) { |
|
1019 | + if (method_exists($this, $loader)) { |
|
1020 | 1020 | $dependency = $this->{$loader}($param_class); |
1021 | 1021 | } else { |
1022 | 1022 | $dependency = $this->create($param_class, array(), $cache_on); |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | // did we successfully find the correct dependency ? |
1027 | - if ( $dependency instanceof $param_class ) { |
|
1027 | + if ($dependency instanceof $param_class) { |
|
1028 | 1028 | // then let's inject it into the incoming array of arguments at the correct location |
1029 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
1030 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
1029 | + if (isset($argument_keys[$index])) { |
|
1030 | + $arguments[$argument_keys[$index]] = $dependency; |
|
1031 | 1031 | } else { |
1032 | - $arguments[ $index ] = $dependency; |
|
1032 | + $arguments[$index] = $dependency; |
|
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | return $arguments; |
@@ -1054,19 +1054,19 @@ discard block |
||
1054 | 1054 | * @param bool $from_db |
1055 | 1055 | * @return void |
1056 | 1056 | */ |
1057 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
1058 | - if ( empty( $class_obj ) ) { |
|
1057 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
1058 | + if (empty($class_obj)) { |
|
1059 | 1059 | return; |
1060 | 1060 | } |
1061 | 1061 | // return newly instantiated class |
1062 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
1063 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
1062 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
1063 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
1064 | 1064 | $this->{$class_abbreviation} = $class_obj; |
1065 | - } else if ( property_exists( $this, $class_name ) ) { |
|
1065 | + } else if (property_exists($this, $class_name)) { |
|
1066 | 1066 | $this->{$class_name} = $class_obj; |
1067 | - } else if ( $class_prefix == 'addon' ) { |
|
1067 | + } else if ($class_prefix == 'addon') { |
|
1068 | 1068 | $this->addons->{$class_name} = $class_obj; |
1069 | - } else if ( ! $from_db ) { |
|
1069 | + } else if ( ! $from_db) { |
|
1070 | 1070 | $this->LIB->{$class_name} = $class_obj; |
1071 | 1071 | } |
1072 | 1072 | } |
@@ -1083,12 +1083,12 @@ discard block |
||
1083 | 1083 | * @param array $arguments |
1084 | 1084 | * @return object |
1085 | 1085 | */ |
1086 | - public static function factory( $classname, $arguments = array() ) { |
|
1087 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
1088 | - if ( $loader instanceof Closure ) { |
|
1089 | - return $loader( $arguments ); |
|
1090 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
1091 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
1086 | + public static function factory($classname, $arguments = array()) { |
|
1087 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
1088 | + if ($loader instanceof Closure) { |
|
1089 | + return $loader($arguments); |
|
1090 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
1091 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
1092 | 1092 | } |
1093 | 1093 | return null; |
1094 | 1094 | } |
@@ -1101,9 +1101,9 @@ discard block |
||
1101 | 1101 | * @param string $name |
1102 | 1102 | * @return EE_Addon |
1103 | 1103 | */ |
1104 | - public function get_addon_by_name( $name ) { |
|
1105 | - foreach ( $this->addons as $addon ) { |
|
1106 | - if ( $addon->name() == $name ) { |
|
1104 | + public function get_addon_by_name($name) { |
|
1105 | + foreach ($this->addons as $addon) { |
|
1106 | + if ($addon->name() == $name) { |
|
1107 | 1107 | return $addon; |
1108 | 1108 | } |
1109 | 1109 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | */ |
1120 | 1120 | public function get_addons_by_name() { |
1121 | 1121 | $addons = array(); |
1122 | - foreach ( $this->addons as $addon ) { |
|
1123 | - $addons[ $addon->name() ] = $addon; |
|
1122 | + foreach ($this->addons as $addon) { |
|
1123 | + $addons[$addon->name()] = $addon; |
|
1124 | 1124 | } |
1125 | 1125 | return $addons; |
1126 | 1126 | } |
@@ -1135,14 +1135,14 @@ discard block |
||
1135 | 1135 | * @return \EEM_Base |
1136 | 1136 | * @throws \EE_Error |
1137 | 1137 | */ |
1138 | - public function reset_model( $model_name ) { |
|
1139 | - $model = $this->load_model( $model_name ); |
|
1140 | - $model_class_name = get_class( $model ); |
|
1138 | + public function reset_model($model_name) { |
|
1139 | + $model = $this->load_model($model_name); |
|
1140 | + $model_class_name = get_class($model); |
|
1141 | 1141 | //get that model reset it and make sure we nuke the old reference to it |
1142 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
1142 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
1143 | 1143 | $this->LIB->{$model_class_name} = $model::reset(); |
1144 | 1144 | } else { |
1145 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
1145 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
1146 | 1146 | } |
1147 | 1147 | return $this->LIB->{$model_class_name}; |
1148 | 1148 | } |
@@ -1179,13 +1179,13 @@ discard block |
||
1179 | 1179 | * |
1180 | 1180 | * @return EE_Registry |
1181 | 1181 | */ |
1182 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
1182 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
1183 | 1183 | $instance = self::instance(); |
1184 | 1184 | EEH_Activation::reset(); |
1185 | 1185 | |
1186 | 1186 | //properties that get reset |
1187 | 1187 | $instance->_cache_on = true; |
1188 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
1188 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
1189 | 1189 | $instance->CART = null; |
1190 | 1190 | $instance->MRM = null; |
1191 | 1191 | $instance->LIB = new stdClass(); |
@@ -1193,9 +1193,9 @@ discard block |
||
1193 | 1193 | //messages reset |
1194 | 1194 | EED_Messages::reset(); |
1195 | 1195 | |
1196 | - if ( $reset_models ) { |
|
1197 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
1198 | - $instance->reset_model( $model_name ); |
|
1196 | + if ($reset_models) { |
|
1197 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
1198 | + $instance->reset_model($model_name); |
|
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | * @param $a |
1218 | 1218 | * @param $b |
1219 | 1219 | */ |
1220 | - final function __call( $a, $b ) { |
|
1220 | + final function __call($a, $b) { |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | /** |
1226 | 1226 | * @param $a |
1227 | 1227 | */ |
1228 | - final function __get( $a ) { |
|
1228 | + final function __get($a) { |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | * @param $a |
1235 | 1235 | * @param $b |
1236 | 1236 | */ |
1237 | - final function __set( $a, $b ) { |
|
1237 | + final function __set($a, $b) { |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | /** |
1243 | 1243 | * @param $a |
1244 | 1244 | */ |
1245 | - final function __isset( $a ) { |
|
1245 | + final function __isset($a) { |
|
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | /** |
1251 | 1251 | * @param $a |
1252 | 1252 | */ |
1253 | - final function __unset( $a ) { |
|
1253 | + final function __unset($a) { |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | * @param $a |
1298 | 1298 | * @param $b |
1299 | 1299 | */ |
1300 | - final static function __callStatic( $a, $b ) { |
|
1300 | + final static function __callStatic($a, $b) { |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | /** |
@@ -1306,9 +1306,9 @@ discard block |
||
1306 | 1306 | */ |
1307 | 1307 | public function cpt_models() { |
1308 | 1308 | $cpt_models = array(); |
1309 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1310 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1311 | - $cpt_models[ $short_name ] = $classname; |
|
1309 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1310 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1311 | + $cpt_models[$short_name] = $classname; |
|
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | return $cpt_models; |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\commands; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param int $code |
26 | 26 | * @param \Exception $previous |
27 | 27 | */ |
28 | - public function __construct( $command_handler_name, $message = '', $code = 0, \Exception $previous = null ) { |
|
29 | - if ( empty( $message ) ) { |
|
28 | + public function __construct($command_handler_name, $message = '', $code = 0, \Exception $previous = null) { |
|
29 | + if (empty($message)) { |
|
30 | 30 | $message = sprintf( |
31 | - __( 'The requested Command Handler "%1$s" could not be located or does not exist.', 'event_espresso' ), |
|
31 | + __('The requested Command Handler "%1$s" could not be located or does not exist.', 'event_espresso'), |
|
32 | 32 | $command_handler_name |
33 | 33 | ); |
34 | 34 | } |
35 | - parent::__construct( $message, $code, $previous ); |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |