Completed
Branch master (0adc3a)
by
unknown
35:26 queued 26:46
created
core/helpers/EEH_Autoloader.helper.php 2 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -15,296 +15,296 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     *    instance of the EE_System object
20
-     *
21
-     * @var    $_instance
22
-     * @access    private
23
-     */
24
-    private static $_instance = null;
25
-
26
-    /**
27
-    *   $_autoloaders
28
-    *   @var array $_autoloaders
29
-    *   @access     private
30
-    */
31
-    private static $_autoloaders;
32
-
33
-    /**
34
-     * set to "paths" to display autoloader class => path mappings
35
-     * set to "times" to display autoloader loading times
36
-     * set to "all" to display both
37
-     *
38
-     * @var string $debug
39
-     * @access    private
40
-     */
41
-    public static $debug = false;
42
-
43
-
44
-    /**
45
-     *    class constructor
46
-     *
47
-     * @access    private
48
-     * @return \EEH_Autoloader
49
-     * @throws Exception
50
-     */
51
-    private function __construct()
52
-    {
53
-        if (self::$_autoloaders === null) {
54
-            self::$_autoloaders = array();
55
-            $this->_register_custom_autoloaders();
56
-            spl_autoload_register(array( $this, 'espresso_autoloader' ));
57
-        }
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * @access public
64
-     * @return EEH_Autoloader
65
-     */
66
-    public static function instance()
67
-    {
68
-        // check if class object is instantiated
69
-        if (! self::$_instance instanceof EEH_Autoloader) {
70
-            self::$_instance = new self();
71
-        }
72
-        return self::$_instance;
73
-    }
74
-
75
-
76
-
77
-    /**
78
-     *    espresso_autoloader
79
-     *
80
-     * @access    public
81
-     * @param   $class_name
82
-     * @internal  param $className
83
-     * @internal  param string $class_name - simple class name ie: session
84
-     * @return  void
85
-     */
86
-    public static function espresso_autoloader($class_name)
87
-    {
88
-        if (isset(self::$_autoloaders[ $class_name ])) {
89
-            require_once(self::$_autoloaders[ $class_name ]);
90
-        }
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     *    register_autoloader
97
-     *
98
-     * @access    public
99
-     * @param array | string $class_paths - array of key => value pairings between class names and paths
100
-     * @param bool           $read_check  true if we need to check whether the file is readable or not.
101
-     * @param bool           $debug **deprecated**
102
-     * @throws \EE_Error
103
-     */
104
-    public static function register_autoloader($class_paths, $read_check = true, $debug = false)
105
-    {
106
-        $class_paths = is_array($class_paths) ? $class_paths : array( $class_paths );
107
-        foreach ($class_paths as $class => $path) {
108
-            // skip all files that are not PHP
109
-            if (substr($path, strlen($path) - 3) !== 'php') {
110
-                continue;
111
-            }
112
-            // don't give up! you gotta...
113
-            // get some class
114
-            if (empty($class)) {
115
-                throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path));
116
-            }
117
-            // one day you will find the path young grasshopper
118
-            if (empty($path)) {
119
-                throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class));
120
-            }
121
-            // is file readable ?
122
-            if ($read_check && ! is_readable($path)) {
123
-                throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path));
124
-            }
125
-            if (! isset(self::$_autoloaders[ $class ])) {
126
-                self::$_autoloaders[ $class ] = str_replace(array( '/', '\\' ), DS, $path);
127
-                if (EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug )) {
128
-                    EEH_Debug_Tools::printr(self::$_autoloaders[ $class ], $class, __FILE__, __LINE__);
129
-                }
130
-            }
131
-        }
132
-    }
133
-
134
-
135
-
136
-
137
-    /**
138
-     *  get_autoloaders
139
-     *
140
-     *  @access public
141
-     *  @return array
142
-     */
143
-    public static function get_autoloaders()
144
-    {
145
-        return self::$_autoloaders;
146
-    }
147
-
148
-
149
-    /**
150
-     *  register core, model and class 'autoloaders'
151
-     *
152
-     * @access private
153
-     * @return void
154
-     * @throws EE_Error
155
-     */
156
-    private function _register_custom_autoloaders()
157
-    {
158
-        EEH_Autoloader::$debug = '';
159
-        \EEH_Autoloader::register_helpers_autoloaders();
160
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces');
161
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE);
162
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true);
163
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true);
164
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES);
165
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true);
166
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'messages');
167
-        if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') {
168
-            EEH_Debug_Tools::instance()->show_times();
169
-        }
170
-    }
171
-
172
-
173
-
174
-    /**
175
-     *    register core, model and class 'autoloaders'
176
-     *
177
-     * @access public
178
-     */
179
-    public static function register_helpers_autoloaders()
180
-    {
181
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
182
-    }
183
-
184
-
185
-
186
-
187
-    /**
188
-     *  register core, model and class 'autoloaders'
189
-     *
190
-     *  @access public
191
-     *  @return void
192
-     */
193
-    public static function register_form_sections_autoloaders()
194
-    {
195
-        // EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true );
196
-    }
197
-
198
-
199
-    /**
200
-     *  register core, model and class 'autoloaders'
201
-     *
202
-     * @access public
203
-     * @return void
204
-     * @throws EE_Error
205
-     */
206
-    public static function register_line_item_display_autoloaders()
207
-    {
208
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_display', true);
209
-    }
210
-
211
-
212
-    /**
213
-     *  register core, model and class 'autoloaders'
214
-     *
215
-     * @access public
216
-     * @return void
217
-     * @throws EE_Error
218
-     */
219
-    public static function register_line_item_filter_autoloaders()
220
-    {
221
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_filters', true);
222
-    }
223
-
224
-
225
-    /**
226
-     *  register template part 'autoloaders'
227
-     *
228
-     * @access public
229
-     * @return void
230
-     * @throws EE_Error
231
-     */
232
-    public static function register_template_part_autoloaders()
233
-    {
234
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'template_parts', true);
235
-    }
236
-
237
-
238
-    /**
239
-     * @return void
240
-     * @throws EE_Error
241
-     */
242
-    public static function register_business_classes()
243
-    {
244
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'business');
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Assumes all the files in this folder have the normal naming scheme (namely that their classname
251
-     * is the file's name, plus ".whatever.php".) and adds each of them to the autoloader list.
252
-     * If that's not the case, you'll need to improve this function or just use EEH_File::get_classname_from_filepath_with_standard_filename() directly.
253
-     * Yes this has to scan the directory for files, but it only does it once -- not on EACH
254
-     * time the autoloader is used
255
-     *
256
-     * @param string $folder name, with or without trailing /, doesn't matter
257
-     * @param bool   $recursive
258
-     * @param bool   $debug  **deprecated**
259
-     * @throws \EE_Error
260
-     */
261
-    public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false)
262
-    {
263
-        if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' || $debug) {
264
-            EEH_Debug_Tools::instance()->start_timer(basename($folder));
265
-        }
266
-        // make sure last char is a /
267
-        $folder .= $folder[ strlen($folder)-1 ] !== DS ? DS : '';
268
-        $class_to_filepath_map = array();
269
-        $exclude = array( 'index' );
270
-        // get all the files in that folder that end in php
271
-        $filepaths = glob($folder.'*');
272
-
273
-        if (empty($filepaths)) {
274
-            return;
275
-        }
276
-
277
-        foreach ($filepaths as $filepath) {
278
-            if (substr($filepath, -4, 4) === '.php') {
279
-                $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath);
280
-                if (! in_array($class_name, $exclude)) {
281
-                    $class_to_filepath_map [ $class_name ] = $filepath;
282
-                }
283
-            } elseif ($recursive) {
284
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug);
285
-            }
286
-        }
287
-        // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories.
288
-        self::register_autoloader($class_to_filepath_map, false, $debug);
289
-        if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') {
290
-            EEH_Debug_Tools::instance()->stop_timer(basename($folder));
291
-        }
292
-    }
293
-
294
-
295
-
296
-    /**
297
-     * add_alias
298
-     * register additional autoloader based on variation of the classname for an existing autoloader
299
-     *
300
-     * @access    public
301
-     * @param string $class_name - simple class name ie: EE_Session
302
-     * @param string $alias - variation on class name ie: EE_session, session, etc
303
-     */
304
-    public static function add_alias($class_name, $alias)
305
-    {
306
-        if (isset(self::$_autoloaders[ $class_name ])) {
307
-            self::$_autoloaders[ $alias ] = self::$_autoloaders[ $class_name ];
308
-        }
309
-    }
18
+	/**
19
+	 *    instance of the EE_System object
20
+	 *
21
+	 * @var    $_instance
22
+	 * @access    private
23
+	 */
24
+	private static $_instance = null;
25
+
26
+	/**
27
+	 *   $_autoloaders
28
+	 *   @var array $_autoloaders
29
+	 *   @access     private
30
+	 */
31
+	private static $_autoloaders;
32
+
33
+	/**
34
+	 * set to "paths" to display autoloader class => path mappings
35
+	 * set to "times" to display autoloader loading times
36
+	 * set to "all" to display both
37
+	 *
38
+	 * @var string $debug
39
+	 * @access    private
40
+	 */
41
+	public static $debug = false;
42
+
43
+
44
+	/**
45
+	 *    class constructor
46
+	 *
47
+	 * @access    private
48
+	 * @return \EEH_Autoloader
49
+	 * @throws Exception
50
+	 */
51
+	private function __construct()
52
+	{
53
+		if (self::$_autoloaders === null) {
54
+			self::$_autoloaders = array();
55
+			$this->_register_custom_autoloaders();
56
+			spl_autoload_register(array( $this, 'espresso_autoloader' ));
57
+		}
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * @access public
64
+	 * @return EEH_Autoloader
65
+	 */
66
+	public static function instance()
67
+	{
68
+		// check if class object is instantiated
69
+		if (! self::$_instance instanceof EEH_Autoloader) {
70
+			self::$_instance = new self();
71
+		}
72
+		return self::$_instance;
73
+	}
74
+
75
+
76
+
77
+	/**
78
+	 *    espresso_autoloader
79
+	 *
80
+	 * @access    public
81
+	 * @param   $class_name
82
+	 * @internal  param $className
83
+	 * @internal  param string $class_name - simple class name ie: session
84
+	 * @return  void
85
+	 */
86
+	public static function espresso_autoloader($class_name)
87
+	{
88
+		if (isset(self::$_autoloaders[ $class_name ])) {
89
+			require_once(self::$_autoloaders[ $class_name ]);
90
+		}
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 *    register_autoloader
97
+	 *
98
+	 * @access    public
99
+	 * @param array | string $class_paths - array of key => value pairings between class names and paths
100
+	 * @param bool           $read_check  true if we need to check whether the file is readable or not.
101
+	 * @param bool           $debug **deprecated**
102
+	 * @throws \EE_Error
103
+	 */
104
+	public static function register_autoloader($class_paths, $read_check = true, $debug = false)
105
+	{
106
+		$class_paths = is_array($class_paths) ? $class_paths : array( $class_paths );
107
+		foreach ($class_paths as $class => $path) {
108
+			// skip all files that are not PHP
109
+			if (substr($path, strlen($path) - 3) !== 'php') {
110
+				continue;
111
+			}
112
+			// don't give up! you gotta...
113
+			// get some class
114
+			if (empty($class)) {
115
+				throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path));
116
+			}
117
+			// one day you will find the path young grasshopper
118
+			if (empty($path)) {
119
+				throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class));
120
+			}
121
+			// is file readable ?
122
+			if ($read_check && ! is_readable($path)) {
123
+				throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path));
124
+			}
125
+			if (! isset(self::$_autoloaders[ $class ])) {
126
+				self::$_autoloaders[ $class ] = str_replace(array( '/', '\\' ), DS, $path);
127
+				if (EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug )) {
128
+					EEH_Debug_Tools::printr(self::$_autoloaders[ $class ], $class, __FILE__, __LINE__);
129
+				}
130
+			}
131
+		}
132
+	}
133
+
134
+
135
+
136
+
137
+	/**
138
+	 *  get_autoloaders
139
+	 *
140
+	 *  @access public
141
+	 *  @return array
142
+	 */
143
+	public static function get_autoloaders()
144
+	{
145
+		return self::$_autoloaders;
146
+	}
147
+
148
+
149
+	/**
150
+	 *  register core, model and class 'autoloaders'
151
+	 *
152
+	 * @access private
153
+	 * @return void
154
+	 * @throws EE_Error
155
+	 */
156
+	private function _register_custom_autoloaders()
157
+	{
158
+		EEH_Autoloader::$debug = '';
159
+		\EEH_Autoloader::register_helpers_autoloaders();
160
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces');
161
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE);
162
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true);
163
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true);
164
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES);
165
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true);
166
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'messages');
167
+		if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') {
168
+			EEH_Debug_Tools::instance()->show_times();
169
+		}
170
+	}
171
+
172
+
173
+
174
+	/**
175
+	 *    register core, model and class 'autoloaders'
176
+	 *
177
+	 * @access public
178
+	 */
179
+	public static function register_helpers_autoloaders()
180
+	{
181
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS);
182
+	}
183
+
184
+
185
+
186
+
187
+	/**
188
+	 *  register core, model and class 'autoloaders'
189
+	 *
190
+	 *  @access public
191
+	 *  @return void
192
+	 */
193
+	public static function register_form_sections_autoloaders()
194
+	{
195
+		// EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true );
196
+	}
197
+
198
+
199
+	/**
200
+	 *  register core, model and class 'autoloaders'
201
+	 *
202
+	 * @access public
203
+	 * @return void
204
+	 * @throws EE_Error
205
+	 */
206
+	public static function register_line_item_display_autoloaders()
207
+	{
208
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_display', true);
209
+	}
210
+
211
+
212
+	/**
213
+	 *  register core, model and class 'autoloaders'
214
+	 *
215
+	 * @access public
216
+	 * @return void
217
+	 * @throws EE_Error
218
+	 */
219
+	public static function register_line_item_filter_autoloaders()
220
+	{
221
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_filters', true);
222
+	}
223
+
224
+
225
+	/**
226
+	 *  register template part 'autoloaders'
227
+	 *
228
+	 * @access public
229
+	 * @return void
230
+	 * @throws EE_Error
231
+	 */
232
+	public static function register_template_part_autoloaders()
233
+	{
234
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'template_parts', true);
235
+	}
236
+
237
+
238
+	/**
239
+	 * @return void
240
+	 * @throws EE_Error
241
+	 */
242
+	public static function register_business_classes()
243
+	{
244
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'business');
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Assumes all the files in this folder have the normal naming scheme (namely that their classname
251
+	 * is the file's name, plus ".whatever.php".) and adds each of them to the autoloader list.
252
+	 * If that's not the case, you'll need to improve this function or just use EEH_File::get_classname_from_filepath_with_standard_filename() directly.
253
+	 * Yes this has to scan the directory for files, but it only does it once -- not on EACH
254
+	 * time the autoloader is used
255
+	 *
256
+	 * @param string $folder name, with or without trailing /, doesn't matter
257
+	 * @param bool   $recursive
258
+	 * @param bool   $debug  **deprecated**
259
+	 * @throws \EE_Error
260
+	 */
261
+	public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false)
262
+	{
263
+		if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' || $debug) {
264
+			EEH_Debug_Tools::instance()->start_timer(basename($folder));
265
+		}
266
+		// make sure last char is a /
267
+		$folder .= $folder[ strlen($folder)-1 ] !== DS ? DS : '';
268
+		$class_to_filepath_map = array();
269
+		$exclude = array( 'index' );
270
+		// get all the files in that folder that end in php
271
+		$filepaths = glob($folder.'*');
272
+
273
+		if (empty($filepaths)) {
274
+			return;
275
+		}
276
+
277
+		foreach ($filepaths as $filepath) {
278
+			if (substr($filepath, -4, 4) === '.php') {
279
+				$class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath);
280
+				if (! in_array($class_name, $exclude)) {
281
+					$class_to_filepath_map [ $class_name ] = $filepath;
282
+				}
283
+			} elseif ($recursive) {
284
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug);
285
+			}
286
+		}
287
+		// we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories.
288
+		self::register_autoloader($class_to_filepath_map, false, $debug);
289
+		if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') {
290
+			EEH_Debug_Tools::instance()->stop_timer(basename($folder));
291
+		}
292
+	}
293
+
294
+
295
+
296
+	/**
297
+	 * add_alias
298
+	 * register additional autoloader based on variation of the classname for an existing autoloader
299
+	 *
300
+	 * @access    public
301
+	 * @param string $class_name - simple class name ie: EE_Session
302
+	 * @param string $alias - variation on class name ie: EE_session, session, etc
303
+	 */
304
+	public static function add_alias($class_name, $alias)
305
+	{
306
+		if (isset(self::$_autoloaders[ $class_name ])) {
307
+			self::$_autoloaders[ $alias ] = self::$_autoloaders[ $class_name ];
308
+		}
309
+	}
310 310
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         if (self::$_autoloaders === null) {
54 54
             self::$_autoloaders = array();
55 55
             $this->_register_custom_autoloaders();
56
-            spl_autoload_register(array( $this, 'espresso_autoloader' ));
56
+            spl_autoload_register(array($this, 'espresso_autoloader'));
57 57
         }
58 58
     }
59 59
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public static function instance()
67 67
     {
68 68
         // check if class object is instantiated
69
-        if (! self::$_instance instanceof EEH_Autoloader) {
69
+        if ( ! self::$_instance instanceof EEH_Autoloader) {
70 70
             self::$_instance = new self();
71 71
         }
72 72
         return self::$_instance;
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public static function espresso_autoloader($class_name)
87 87
     {
88
-        if (isset(self::$_autoloaders[ $class_name ])) {
89
-            require_once(self::$_autoloaders[ $class_name ]);
88
+        if (isset(self::$_autoloaders[$class_name])) {
89
+            require_once(self::$_autoloaders[$class_name]);
90 90
         }
91 91
     }
92 92
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public static function register_autoloader($class_paths, $read_check = true, $debug = false)
105 105
     {
106
-        $class_paths = is_array($class_paths) ? $class_paths : array( $class_paths );
106
+        $class_paths = is_array($class_paths) ? $class_paths : array($class_paths);
107 107
         foreach ($class_paths as $class => $path) {
108 108
             // skip all files that are not PHP
109 109
             if (substr($path, strlen($path) - 3) !== 'php') {
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
             if ($read_check && ! is_readable($path)) {
123 123
                 throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path));
124 124
             }
125
-            if (! isset(self::$_autoloaders[ $class ])) {
126
-                self::$_autoloaders[ $class ] = str_replace(array( '/', '\\' ), DS, $path);
127
-                if (EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug )) {
128
-                    EEH_Debug_Tools::printr(self::$_autoloaders[ $class ], $class, __FILE__, __LINE__);
125
+            if ( ! isset(self::$_autoloaders[$class])) {
126
+                self::$_autoloaders[$class] = str_replace(array('/', '\\'), DS, $path);
127
+                if (EE_DEBUG && (EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug)) {
128
+                    EEH_Debug_Tools::printr(self::$_autoloaders[$class], $class, __FILE__, __LINE__);
129 129
                 }
130 130
             }
131 131
         }
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
     {
158 158
         EEH_Autoloader::$debug = '';
159 159
         \EEH_Autoloader::register_helpers_autoloaders();
160
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces');
160
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces');
161 161
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE);
162 162
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true);
163 163
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true);
164 164
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES);
165 165
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true);
166
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'messages');
166
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'messages');
167 167
         if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') {
168 168
             EEH_Debug_Tools::instance()->show_times();
169 169
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public static function register_line_item_display_autoloaders()
207 207
     {
208
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_display', true);
208
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true);
209 209
     }
210 210
 
211 211
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      */
219 219
     public static function register_line_item_filter_autoloaders()
220 220
     {
221
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_filters', true);
221
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true);
222 222
     }
223 223
 
224 224
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public static function register_template_part_autoloaders()
233 233
     {
234
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'template_parts', true);
234
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'template_parts', true);
235 235
     }
236 236
 
237 237
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public static function register_business_classes()
243 243
     {
244
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'business');
244
+        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'business');
245 245
     }
246 246
 
247 247
 
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
             EEH_Debug_Tools::instance()->start_timer(basename($folder));
265 265
         }
266 266
         // make sure last char is a /
267
-        $folder .= $folder[ strlen($folder)-1 ] !== DS ? DS : '';
267
+        $folder .= $folder[strlen($folder) - 1] !== DS ? DS : '';
268 268
         $class_to_filepath_map = array();
269
-        $exclude = array( 'index' );
269
+        $exclude = array('index');
270 270
         // get all the files in that folder that end in php
271 271
         $filepaths = glob($folder.'*');
272 272
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
         foreach ($filepaths as $filepath) {
278 278
             if (substr($filepath, -4, 4) === '.php') {
279 279
                 $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath);
280
-                if (! in_array($class_name, $exclude)) {
281
-                    $class_to_filepath_map [ $class_name ] = $filepath;
280
+                if ( ! in_array($class_name, $exclude)) {
281
+                    $class_to_filepath_map [$class_name] = $filepath;
282 282
                 }
283 283
             } elseif ($recursive) {
284 284
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug);
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
      */
304 304
     public static function add_alias($class_name, $alias)
305 305
     {
306
-        if (isset(self::$_autoloaders[ $class_name ])) {
307
-            self::$_autoloaders[ $alias ] = self::$_autoloaders[ $class_name ];
306
+        if (isset(self::$_autoloaders[$class_name])) {
307
+            self::$_autoloaders[$alias] = self::$_autoloaders[$class_name];
308 308
         }
309 309
     }
310 310
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Form_Section_Layout_Base.strategy.php 2 patches
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -12,288 +12,288 @@
 block discarded – undo
12 12
 abstract class EE_Form_Section_Layout_Base
13 13
 {
14 14
 
15
-    /**
16
-     * Form form section to lay out
17
-     *
18
-     * @var EE_Form_Section_Proper
19
-     */
20
-    protected $_form_section;
21
-
22
-
23
-
24
-    /**
25
-     *  __construct
26
-     */
27
-    public function __construct()
28
-    {
29
-    }
30
-
31
-
32
-
33
-    /**
34
-     * The form section on which this strategy is to perform
35
-     *
36
-     * @param EE_Form_Section_Proper $form
37
-     */
38
-    public function _construct_finalize(EE_Form_Section_Proper $form)
39
-    {
40
-        $this->_form_section = $form;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * @return EE_Form_Section_Proper
47
-     */
48
-    public function form_section()
49
-    {
50
-        return $this->_form_section;
51
-    }
52
-
53
-
54
-
55
-    /**
56
-     * Also has teh side effect of enqueuing any needed JS and CSS for
57
-     * this form.
58
-     * Creates all the HTML necessary for displaying this form, its inputs, and
59
-     * proper subsections.
60
-     * Returns the HTML
61
-     *
62
-     * @return string HTML for displaying
63
-     * @throws EE_Error
64
-     */
65
-    public function layout_form()
66
-    {
67
-        $html = '';
68
-        // layout_form_begin
69
-        $html .= apply_filters(
70
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
71
-            $this->layout_form_begin(),
72
-            $this->_form_section
73
-        );
74
-        // layout_form_loop
75
-        $html .= apply_filters(
76
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
77
-            $this->layout_form_loop(),
78
-            $this->_form_section
79
-        );
80
-        // layout_form_end
81
-        $html .= apply_filters(
82
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
83
-            $this->layout_form_end(),
84
-            $this->_form_section
85
-        );
86
-        $html = $this->add_form_section_hooks_and_filters($html);
87
-        return $html;
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * @return string
94
-     * @throws EE_Error
95
-     */
96
-    public function layout_form_loop()
97
-    {
98
-        $html = '';
99
-        foreach ($this->_form_section->subsections() as $name => $subsection) {
100
-            if ($subsection instanceof EE_Form_Input_Base) {
101
-                $html .= apply_filters(
102
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
-                    . $name . '__in_' . $this->_form_section->name(),
104
-                    $this->layout_input($subsection),
105
-                    $this->_form_section,
106
-                    $subsection
107
-                );
108
-            } elseif ($subsection instanceof EE_Form_Section_Base) {
109
-                $html .= apply_filters(
110
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
-                    . $name . '__in_' . $this->_form_section->name(),
112
-                    $this->layout_subsection($subsection),
113
-                    $this->_form_section,
114
-                    $subsection
115
-                );
116
-            }
117
-        }
118
-        return $html;
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
125
-     *
126
-     * @return string
127
-     */
128
-    abstract public function layout_form_begin();
129
-
130
-
131
-
132
-    /**
133
-     * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
134
-     *
135
-     * @return string
136
-     */
137
-    abstract public function layout_form_end();
138
-
139
-
140
-
141
-    /**
142
-     * Should be used internally by layout_form() to layout each input (eg, if this layout
143
-     * is putting each input in a row of its own, this should probably be called by a
144
-     *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
145
-     * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
146
-     * customize the form's layout, but would like to make use of it for laying out
147
-     * 'easy-to-layout' inputs
148
-     *
149
-     * @param EE_Form_Input_Base $input
150
-     * @return string html
151
-     */
152
-    abstract public function layout_input($input);
153
-
154
-
155
-
156
-    /**
157
-     * Similar to layout_input(), should be used internally by layout_form() within a
158
-     * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed
159
-     * that the proper subsection will layout its container, label, etc on its own.
160
-     *
161
-     * @param EE_Form_Section_Base $subsection
162
-     * @return string html
163
-     */
164
-    abstract public function layout_subsection($subsection);
165
-
166
-
167
-
168
-    /**
169
-     * Gets the HTML for the label tag and its contents for the input
170
-     *
171
-     * @param EE_Form_Input_Base $input
172
-     * @return string
173
-     */
174
-    public function display_label($input)
175
-    {
176
-        if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
177
-            return '';
178
-        }
179
-        $class = $input->required()
180
-            ? 'ee-required-label ' . $input->html_label_class()
181
-            : $input->html_label_class();
182
-        $label_text = $input->required()
183
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
184
-            : $input->html_label_text();
185
-        return '<label id="'
186
-               . $input->html_label_id()
187
-               . '" class="'
188
-               . $class
189
-               . '" style="'
190
-               . $input->html_label_style()
191
-               . '" for="' . $input->html_id()
192
-               . '">'
193
-               . $label_text
194
-               . '</label>';
195
-    }
196
-
197
-
198
-
199
-    /**
200
-     * Gets the HTML for all the form's form-wide errors (ie, errors which
201
-     * are not for specific inputs. E.g., if two inputs somehow disagree,
202
-     * those errors would probably be on the form section, not one of its inputs)
203
-     * @return string
204
-     */
205
-    public function display_form_wide_errors()
206
-    {
207
-        $html = '';
208
-        if ($this->_form_section->get_validation_errors()) {
209
-            $html .= "<div class='ee-form-wide-errors'>";
210
-            // get all the errors on THIS form section (errors which aren't
211
-            // for specific inputs, but instead for the entire form section)
212
-            foreach ($this->_form_section->get_validation_errors() as $error) {
213
-                $html .= $error->getMessage() . '<br>';
214
-            }
215
-            $html .= '</div>';
216
-        }
217
-        return apply_filters(
218
-            'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
219
-            $html,
220
-            $this
221
-        );
222
-    }
223
-
224
-
225
-
226
-    /**
227
-     * returns the HTML for the server-side validation errors for the specified input
228
-     * Note that if JS is enabled, it should remove these and instead
229
-     * populate the form's errors in the jquery validate fashion
230
-     * using the localized data provided to the JS
231
-     *
232
-     * @param EE_Form_Input_Base $input
233
-     * @return string
234
-     */
235
-    public function display_errors($input)
236
-    {
237
-        if ($input->get_validation_errors()) {
238
-            return "<label  id='"
239
-                   . $input->html_id()
240
-                   . "-error' class='error' for='{$input->html_name()}'>"
241
-                   . $input->get_validation_error_string()
242
-                   . '</label>';
243
-        }
244
-        return '';
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Displays the help span for the specified input
251
-     *
252
-     * @param EE_Form_Input_Base $input
253
-     * @return string
254
-     */
255
-    public function display_help_text($input)
256
-    {
257
-        $help_text  = $input->html_help_text();
258
-        if ($help_text !== '' && $help_text !== null) {
259
-            $tag = is_admin() ? 'p' : 'span';
260
-            return '<'
261
-                   . $tag
262
-                   . ' id="'
263
-                   . $input->html_id()
264
-                   . '-help" class="'
265
-                   . $input->html_help_class()
266
-                   . '" style="'
267
-                   . $input->html_help_style()
268
-                   . '">'
269
-                   . $help_text
270
-                   . '</'
271
-                   . $tag
272
-                   . '>';
273
-        }
274
-        return '';
275
-    }
276
-
277
-
278
-
279
-    /**
280
-     * Does an action and hook onto the end of teh form
281
-     *
282
-     * @param string $html
283
-     * @return string
284
-     */
285
-    public function add_form_section_hooks_and_filters($html)
286
-    {
287
-        // replace dashes and spaces with underscores
288
-        $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
290
-        $html = (string) apply_filters(
291
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
292
-            $html,
293
-            $this->_form_section
294
-        );
295
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
297
-        return $html;
298
-    }
15
+	/**
16
+	 * Form form section to lay out
17
+	 *
18
+	 * @var EE_Form_Section_Proper
19
+	 */
20
+	protected $_form_section;
21
+
22
+
23
+
24
+	/**
25
+	 *  __construct
26
+	 */
27
+	public function __construct()
28
+	{
29
+	}
30
+
31
+
32
+
33
+	/**
34
+	 * The form section on which this strategy is to perform
35
+	 *
36
+	 * @param EE_Form_Section_Proper $form
37
+	 */
38
+	public function _construct_finalize(EE_Form_Section_Proper $form)
39
+	{
40
+		$this->_form_section = $form;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * @return EE_Form_Section_Proper
47
+	 */
48
+	public function form_section()
49
+	{
50
+		return $this->_form_section;
51
+	}
52
+
53
+
54
+
55
+	/**
56
+	 * Also has teh side effect of enqueuing any needed JS and CSS for
57
+	 * this form.
58
+	 * Creates all the HTML necessary for displaying this form, its inputs, and
59
+	 * proper subsections.
60
+	 * Returns the HTML
61
+	 *
62
+	 * @return string HTML for displaying
63
+	 * @throws EE_Error
64
+	 */
65
+	public function layout_form()
66
+	{
67
+		$html = '';
68
+		// layout_form_begin
69
+		$html .= apply_filters(
70
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
71
+			$this->layout_form_begin(),
72
+			$this->_form_section
73
+		);
74
+		// layout_form_loop
75
+		$html .= apply_filters(
76
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
77
+			$this->layout_form_loop(),
78
+			$this->_form_section
79
+		);
80
+		// layout_form_end
81
+		$html .= apply_filters(
82
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
83
+			$this->layout_form_end(),
84
+			$this->_form_section
85
+		);
86
+		$html = $this->add_form_section_hooks_and_filters($html);
87
+		return $html;
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * @return string
94
+	 * @throws EE_Error
95
+	 */
96
+	public function layout_form_loop()
97
+	{
98
+		$html = '';
99
+		foreach ($this->_form_section->subsections() as $name => $subsection) {
100
+			if ($subsection instanceof EE_Form_Input_Base) {
101
+				$html .= apply_filters(
102
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
+					. $name . '__in_' . $this->_form_section->name(),
104
+					$this->layout_input($subsection),
105
+					$this->_form_section,
106
+					$subsection
107
+				);
108
+			} elseif ($subsection instanceof EE_Form_Section_Base) {
109
+				$html .= apply_filters(
110
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
+					. $name . '__in_' . $this->_form_section->name(),
112
+					$this->layout_subsection($subsection),
113
+					$this->_form_section,
114
+					$subsection
115
+				);
116
+			}
117
+		}
118
+		return $html;
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
125
+	 *
126
+	 * @return string
127
+	 */
128
+	abstract public function layout_form_begin();
129
+
130
+
131
+
132
+	/**
133
+	 * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
134
+	 *
135
+	 * @return string
136
+	 */
137
+	abstract public function layout_form_end();
138
+
139
+
140
+
141
+	/**
142
+	 * Should be used internally by layout_form() to layout each input (eg, if this layout
143
+	 * is putting each input in a row of its own, this should probably be called by a
144
+	 *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
145
+	 * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
146
+	 * customize the form's layout, but would like to make use of it for laying out
147
+	 * 'easy-to-layout' inputs
148
+	 *
149
+	 * @param EE_Form_Input_Base $input
150
+	 * @return string html
151
+	 */
152
+	abstract public function layout_input($input);
153
+
154
+
155
+
156
+	/**
157
+	 * Similar to layout_input(), should be used internally by layout_form() within a
158
+	 * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed
159
+	 * that the proper subsection will layout its container, label, etc on its own.
160
+	 *
161
+	 * @param EE_Form_Section_Base $subsection
162
+	 * @return string html
163
+	 */
164
+	abstract public function layout_subsection($subsection);
165
+
166
+
167
+
168
+	/**
169
+	 * Gets the HTML for the label tag and its contents for the input
170
+	 *
171
+	 * @param EE_Form_Input_Base $input
172
+	 * @return string
173
+	 */
174
+	public function display_label($input)
175
+	{
176
+		if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
177
+			return '';
178
+		}
179
+		$class = $input->required()
180
+			? 'ee-required-label ' . $input->html_label_class()
181
+			: $input->html_label_class();
182
+		$label_text = $input->required()
183
+			? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
184
+			: $input->html_label_text();
185
+		return '<label id="'
186
+			   . $input->html_label_id()
187
+			   . '" class="'
188
+			   . $class
189
+			   . '" style="'
190
+			   . $input->html_label_style()
191
+			   . '" for="' . $input->html_id()
192
+			   . '">'
193
+			   . $label_text
194
+			   . '</label>';
195
+	}
196
+
197
+
198
+
199
+	/**
200
+	 * Gets the HTML for all the form's form-wide errors (ie, errors which
201
+	 * are not for specific inputs. E.g., if two inputs somehow disagree,
202
+	 * those errors would probably be on the form section, not one of its inputs)
203
+	 * @return string
204
+	 */
205
+	public function display_form_wide_errors()
206
+	{
207
+		$html = '';
208
+		if ($this->_form_section->get_validation_errors()) {
209
+			$html .= "<div class='ee-form-wide-errors'>";
210
+			// get all the errors on THIS form section (errors which aren't
211
+			// for specific inputs, but instead for the entire form section)
212
+			foreach ($this->_form_section->get_validation_errors() as $error) {
213
+				$html .= $error->getMessage() . '<br>';
214
+			}
215
+			$html .= '</div>';
216
+		}
217
+		return apply_filters(
218
+			'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
219
+			$html,
220
+			$this
221
+		);
222
+	}
223
+
224
+
225
+
226
+	/**
227
+	 * returns the HTML for the server-side validation errors for the specified input
228
+	 * Note that if JS is enabled, it should remove these and instead
229
+	 * populate the form's errors in the jquery validate fashion
230
+	 * using the localized data provided to the JS
231
+	 *
232
+	 * @param EE_Form_Input_Base $input
233
+	 * @return string
234
+	 */
235
+	public function display_errors($input)
236
+	{
237
+		if ($input->get_validation_errors()) {
238
+			return "<label  id='"
239
+				   . $input->html_id()
240
+				   . "-error' class='error' for='{$input->html_name()}'>"
241
+				   . $input->get_validation_error_string()
242
+				   . '</label>';
243
+		}
244
+		return '';
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Displays the help span for the specified input
251
+	 *
252
+	 * @param EE_Form_Input_Base $input
253
+	 * @return string
254
+	 */
255
+	public function display_help_text($input)
256
+	{
257
+		$help_text  = $input->html_help_text();
258
+		if ($help_text !== '' && $help_text !== null) {
259
+			$tag = is_admin() ? 'p' : 'span';
260
+			return '<'
261
+				   . $tag
262
+				   . ' id="'
263
+				   . $input->html_id()
264
+				   . '-help" class="'
265
+				   . $input->html_help_class()
266
+				   . '" style="'
267
+				   . $input->html_help_style()
268
+				   . '">'
269
+				   . $help_text
270
+				   . '</'
271
+				   . $tag
272
+				   . '>';
273
+		}
274
+		return '';
275
+	}
276
+
277
+
278
+
279
+	/**
280
+	 * Does an action and hook onto the end of teh form
281
+	 *
282
+	 * @param string $html
283
+	 * @return string
284
+	 */
285
+	public function add_form_section_hooks_and_filters($html)
286
+	{
287
+		// replace dashes and spaces with underscores
288
+		$hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
+		do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
290
+		$html = (string) apply_filters(
291
+			'AFEE__Form_Section_Layout__' . $hook_name . '__html',
292
+			$html,
293
+			$this->_form_section
294
+		);
295
+		$html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
+		$html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
297
+		return $html;
298
+	}
299 299
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
         $html = '';
68 68
         // layout_form_begin
69 69
         $html .= apply_filters(
70
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(),
71 71
             $this->layout_form_begin(),
72 72
             $this->_form_section
73 73
         );
74 74
         // layout_form_loop
75 75
         $html .= apply_filters(
76
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(),
77 77
             $this->layout_form_loop(),
78 78
             $this->_form_section
79 79
         );
80 80
         // layout_form_end
81 81
         $html .= apply_filters(
82
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(),
83 83
             $this->layout_form_end(),
84 84
             $this->_form_section
85 85
         );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             if ($subsection instanceof EE_Form_Input_Base) {
101 101
                 $html .= apply_filters(
102 102
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
-                    . $name . '__in_' . $this->_form_section->name(),
103
+                    . $name.'__in_'.$this->_form_section->name(),
104 104
                     $this->layout_input($subsection),
105 105
                     $this->_form_section,
106 106
                     $subsection
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             } elseif ($subsection instanceof EE_Form_Section_Base) {
109 109
                 $html .= apply_filters(
110 110
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
-                    . $name . '__in_' . $this->_form_section->name(),
111
+                    . $name.'__in_'.$this->_form_section->name(),
112 112
                     $this->layout_subsection($subsection),
113 113
                     $this->_form_section,
114 114
                     $subsection
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
             return '';
178 178
         }
179 179
         $class = $input->required()
180
-            ? 'ee-required-label ' . $input->html_label_class()
180
+            ? 'ee-required-label '.$input->html_label_class()
181 181
             : $input->html_label_class();
182 182
         $label_text = $input->required()
183
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
183
+            ? $input->html_label_text().'<span class="ee-asterisk">*</span>'
184 184
             : $input->html_label_text();
185 185
         return '<label id="'
186 186
                . $input->html_label_id()
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                . $class
189 189
                . '" style="'
190 190
                . $input->html_label_style()
191
-               . '" for="' . $input->html_id()
191
+               . '" for="'.$input->html_id()
192 192
                . '">'
193 193
                . $label_text
194 194
                . '</label>';
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             // get all the errors on THIS form section (errors which aren't
211 211
             // for specific inputs, but instead for the entire form section)
212 212
             foreach ($this->_form_section->get_validation_errors() as $error) {
213
-                $html .= $error->getMessage() . '<br>';
213
+                $html .= $error->getMessage().'<br>';
214 214
             }
215 215
             $html .= '</div>';
216 216
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function display_help_text($input)
256 256
     {
257
-        $help_text  = $input->html_help_text();
257
+        $help_text = $input->html_help_text();
258 258
         if ($help_text !== '' && $help_text !== null) {
259 259
             $tag = is_admin() ? 'p' : 'span';
260 260
             return '<'
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
     {
287 287
         // replace dashes and spaces with underscores
288 288
         $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
289
+        do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section);
290 290
         $html = (string) apply_filters(
291
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
291
+            'AFEE__Form_Section_Layout__'.$hook_name.'__html',
292 292
             $html,
293 293
             $this->_form_section
294 294
         );
295
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
+        $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->';
296
+        $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->';
297 297
         return $html;
298 298
     }
299 299
 }
Please login to merge, or discard this patch.
core/services/commands/registration/CreateRegistrationCommandHandler.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 
41 41
     /**
42 42
      * @param  CommandInterface|CreateRegistrationCommand $command
43
-     * @return mixed
43
+     * @return \EE_Registration
44 44
      * @throws OutOfRangeException
45 45
      * @throws UnexpectedEntityException
46 46
      * @throws EE_Error
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,42 +21,42 @@
 block discarded – undo
21 21
 class CreateRegistrationCommandHandler extends CommandHandler
22 22
 {
23 23
 
24
-    /**
25
-     * @var CreateRegistrationService $registration_service
26
-     */
27
-    private $registration_service;
28
-
29
-
30
-    /**
31
-     * Command constructor
32
-     *
33
-     * @param CreateRegistrationService $registration_service
34
-     */
35
-    public function __construct(CreateRegistrationService $registration_service)
36
-    {
37
-        $this->registration_service = $registration_service;
38
-    }
39
-
40
-
41
-    /**
42
-     * @param  CommandInterface|CreateRegistrationCommand $command
43
-     * @return mixed
44
-     * @throws OutOfRangeException
45
-     * @throws UnexpectedEntityException
46
-     * @throws EE_Error
47
-     * @throws InvalidEntityException
48
-     */
49
-    public function handle(CommandInterface $command)
50
-    {
51
-        // now create a new registration for the ticket
52
-        return $this->registration_service->create(
53
-            $command->ticket()->get_related_event(),
54
-            $command->transaction(),
55
-            $command->ticket(),
56
-            $command->ticketLineItem(),
57
-            $command->regCount(),
58
-            $command->regGroupSize(),
59
-            $command->regStatus()
60
-        );
61
-    }
24
+	/**
25
+	 * @var CreateRegistrationService $registration_service
26
+	 */
27
+	private $registration_service;
28
+
29
+
30
+	/**
31
+	 * Command constructor
32
+	 *
33
+	 * @param CreateRegistrationService $registration_service
34
+	 */
35
+	public function __construct(CreateRegistrationService $registration_service)
36
+	{
37
+		$this->registration_service = $registration_service;
38
+	}
39
+
40
+
41
+	/**
42
+	 * @param  CommandInterface|CreateRegistrationCommand $command
43
+	 * @return mixed
44
+	 * @throws OutOfRangeException
45
+	 * @throws UnexpectedEntityException
46
+	 * @throws EE_Error
47
+	 * @throws InvalidEntityException
48
+	 */
49
+	public function handle(CommandInterface $command)
50
+	{
51
+		// now create a new registration for the ticket
52
+		return $this->registration_service->create(
53
+			$command->ticket()->get_related_event(),
54
+			$command->transaction(),
55
+			$command->ticket(),
56
+			$command->ticketLineItem(),
57
+			$command->regCount(),
58
+			$command->regGroupSize(),
59
+			$command->regStatus()
60
+		);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
core/services/commands/transaction/CreateTransactionCommandHandler.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
     /**
30 30
      * @param CommandInterface|CreateTransactionCommand $command
31
-     * @return mixed
31
+     * @return EE_Transaction
32 32
      * @throws EE_Error
33 33
      * @throws InvalidEntityException
34 34
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -26,43 +26,43 @@
 block discarded – undo
26 26
 class CreateTransactionCommandHandler extends CommandHandler
27 27
 {
28 28
 
29
-    /**
30
-     * @param CommandInterface|CreateTransactionCommand $command
31
-     * @return mixed
32
-     * @throws EE_Error
33
-     * @throws InvalidEntityException
34
-     * @throws InvalidDataTypeException
35
-     * @throws InvalidInterfaceException
36
-     * @throws InvalidArgumentException
37
-     * @throws ReflectionException
38
-     * @throws RuntimeException
39
-     */
40
-    public function handle(CommandInterface $command)
41
-    {
42
-        $transaction_details = $command->transactionDetails();
43
-        $cart_total = null;
44
-        if ($command->checkout() instanceof EE_Checkout) {
45
-            // ensure cart totals have been calculated
46
-            $command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes();
47
-            // grab the cart grand total
48
-            $cart_total = $command->checkout()->cart->get_cart_grand_total();
49
-            $transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array();
50
-            $transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0;
51
-        }
52
-        // create new TXN and save it so it has an ID
53
-        $transaction = EE_Transaction::new_instance($transaction_details);
54
-        if (! $transaction instanceof EE_Transaction) {
55
-            throw new InvalidEntityException(get_class($transaction), 'EE_Transaction');
56
-        }
57
-        $transaction->save();
58
-        // ensure grand total line item created
59
-        $cart_total = $cart_total instanceof EE_Line_Item
60
-            ? $cart_total
61
-            : EEH_Line_Item::create_total_line_item($transaction);
62
-        if (! $cart_total instanceof EE_Line_Item) {
63
-            throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item');
64
-        }
65
-        $cart_total->save_this_and_descendants_to_txn($transaction->ID());
66
-        return $transaction;
67
-    }
29
+	/**
30
+	 * @param CommandInterface|CreateTransactionCommand $command
31
+	 * @return mixed
32
+	 * @throws EE_Error
33
+	 * @throws InvalidEntityException
34
+	 * @throws InvalidDataTypeException
35
+	 * @throws InvalidInterfaceException
36
+	 * @throws InvalidArgumentException
37
+	 * @throws ReflectionException
38
+	 * @throws RuntimeException
39
+	 */
40
+	public function handle(CommandInterface $command)
41
+	{
42
+		$transaction_details = $command->transactionDetails();
43
+		$cart_total = null;
44
+		if ($command->checkout() instanceof EE_Checkout) {
45
+			// ensure cart totals have been calculated
46
+			$command->checkout()->cart->get_grand_total()->recalculate_total_including_taxes();
47
+			// grab the cart grand total
48
+			$cart_total = $command->checkout()->cart->get_cart_grand_total();
49
+			$transaction_details['TXN_reg_steps'] = $command->checkout()->initialize_txn_reg_steps_array();
50
+			$transaction_details['TXN_total'] = $cart_total > 0 ? $cart_total : 0;
51
+		}
52
+		// create new TXN and save it so it has an ID
53
+		$transaction = EE_Transaction::new_instance($transaction_details);
54
+		if (! $transaction instanceof EE_Transaction) {
55
+			throw new InvalidEntityException(get_class($transaction), 'EE_Transaction');
56
+		}
57
+		$transaction->save();
58
+		// ensure grand total line item created
59
+		$cart_total = $cart_total instanceof EE_Line_Item
60
+			? $cart_total
61
+			: EEH_Line_Item::create_total_line_item($transaction);
62
+		if (! $cart_total instanceof EE_Line_Item) {
63
+			throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item');
64
+		}
65
+		$cart_total->save_this_and_descendants_to_txn($transaction->ID());
66
+		return $transaction;
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         }
52 52
         // create new TXN and save it so it has an ID
53 53
         $transaction = EE_Transaction::new_instance($transaction_details);
54
-        if (! $transaction instanceof EE_Transaction) {
54
+        if ( ! $transaction instanceof EE_Transaction) {
55 55
             throw new InvalidEntityException(get_class($transaction), 'EE_Transaction');
56 56
         }
57 57
         $transaction->save();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $cart_total = $cart_total instanceof EE_Line_Item
60 60
             ? $cart_total
61 61
             : EEH_Line_Item::create_total_line_item($transaction);
62
-        if (! $cart_total instanceof EE_Line_Item) {
62
+        if ( ! $cart_total instanceof EE_Line_Item) {
63 63
             throw new InvalidEntityException(get_class($cart_total), 'EE_Line_Item');
64 64
         }
65 65
         $cart_total->save_this_and_descendants_to_txn($transaction->ID());
Please login to merge, or discard this patch.
core/exceptions/InvalidEntityException.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@
 block discarded – undo
16 16
 class InvalidEntityException extends InvalidArgumentException
17 17
 {
18 18
 
19
-    /**
20
-     * InvalidEntityException constructor.
21
-     *
22
-     * @param mixed     $actual   the actual object (or thing) we got
23
-     * @param string    $expected classname of the entity we wanted
24
-     * @param string    $message
25
-     * @param int       $code
26
-     * @param Exception $previous
27
-     */
28
-    public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null)
29
-    {
30
-        if (empty($message)) {
31
-            ob_start();
32
-            var_dump($actual);
33
-            $object = ob_get_clean();
34
-            $message = sprintf(
35
-                __(
36
-                    'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s',
37
-                    'event_espresso'
38
-                ),
39
-                is_object($actual)
40
-                    ? get_class($actual)
41
-                    : gettype($actual),
42
-                $expected,
43
-                $object
44
-            );
45
-        }
46
-        parent::__construct($message, $code, $previous);
47
-    }
19
+	/**
20
+	 * InvalidEntityException constructor.
21
+	 *
22
+	 * @param mixed     $actual   the actual object (or thing) we got
23
+	 * @param string    $expected classname of the entity we wanted
24
+	 * @param string    $message
25
+	 * @param int       $code
26
+	 * @param Exception $previous
27
+	 */
28
+	public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null)
29
+	{
30
+		if (empty($message)) {
31
+			ob_start();
32
+			var_dump($actual);
33
+			$object = ob_get_clean();
34
+			$message = sprintf(
35
+				__(
36
+					'The supplied entity is an instance of "%1$s", but an instance of "%2$s" was expected. Object: %3$s',
37
+					'event_espresso'
38
+				),
39
+				is_object($actual)
40
+					? get_class($actual)
41
+					: gettype($actual),
42
+				$expected,
43
+				$object
44
+			);
45
+		}
46
+		parent::__construct($message, $code, $previous);
47
+	}
48 48
 }
Please login to merge, or discard this patch.
core/services/commands/CommandHandler.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -14,26 +14,26 @@
 block discarded – undo
14 14
  */
15 15
 abstract class CommandHandler implements CommandHandlerInterface
16 16
 {
17
-    /**
18
-     * Verifies the Command class matches the Handler class
19
-     * by simply removing "Handler" from the Command class and then comparing.
20
-     * IF the Command Handler has been changed via CommandHandlerManager::addCommandHandler,
21
-     * or via the filter in CommandHandlerManager::getCommandHandler(),
22
-     * then this method MUST be overridden in the new Command Handler class.
23
-     * PLZ NOTE: that it also needs to return itself ($this)
24
-     * because the CommandBus utilizes method chaining.
25
-     *
26
-     * @param CommandInterface $command
27
-     * @return CommandHandler
28
-     * @throws InvalidEntityException
29
-     * @since $VID:$
30
-     */
31
-    public function verify(CommandInterface $command)
32
-    {
33
-        $expected = str_replace('CommandHandler', 'Command', get_class($this));
34
-        if (! $command instanceof $expected) {
35
-            throw new InvalidEntityException($command, $expected);
36
-        }
37
-        return $this;
38
-    }
17
+	/**
18
+	 * Verifies the Command class matches the Handler class
19
+	 * by simply removing "Handler" from the Command class and then comparing.
20
+	 * IF the Command Handler has been changed via CommandHandlerManager::addCommandHandler,
21
+	 * or via the filter in CommandHandlerManager::getCommandHandler(),
22
+	 * then this method MUST be overridden in the new Command Handler class.
23
+	 * PLZ NOTE: that it also needs to return itself ($this)
24
+	 * because the CommandBus utilizes method chaining.
25
+	 *
26
+	 * @param CommandInterface $command
27
+	 * @return CommandHandler
28
+	 * @throws InvalidEntityException
29
+	 * @since $VID:$
30
+	 */
31
+	public function verify(CommandInterface $command)
32
+	{
33
+		$expected = str_replace('CommandHandler', 'Command', get_class($this));
34
+		if (! $command instanceof $expected) {
35
+			throw new InvalidEntityException($command, $expected);
36
+		}
37
+		return $this;
38
+	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     public function verify(CommandInterface $command)
32 32
     {
33 33
         $expected = str_replace('CommandHandler', 'Command', get_class($this));
34
-        if (! $command instanceof $expected) {
34
+        if ( ! $command instanceof $expected) {
35 35
             throw new InvalidEntityException($command, $expected);
36 36
         }
37 37
         return $this;
Please login to merge, or discard this patch.
core/services/commands/CommandHandlerInterface.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  */
9 9
 interface CommandHandlerInterface
10 10
 {
11
-    /**
12
-     * verifies that the supplied command is the correct class for the handler.
13
-     *
14
-     * !!! IMPORTANT !!!
15
-     * Must return $this (ie: the handler itself)
16
-     * as the CommandBus utilizes method chaining
17
-     *
18
-     * @param CommandInterface $command
19
-     * @return CommandHandlerInterface
20
-     * @since $VID:$
21
-     */
22
-    public function verify(CommandInterface $command);
11
+	/**
12
+	 * verifies that the supplied command is the correct class for the handler.
13
+	 *
14
+	 * !!! IMPORTANT !!!
15
+	 * Must return $this (ie: the handler itself)
16
+	 * as the CommandBus utilizes method chaining
17
+	 *
18
+	 * @param CommandInterface $command
19
+	 * @return CommandHandlerInterface
20
+	 * @since $VID:$
21
+	 */
22
+	public function verify(CommandInterface $command);
23 23
 
24
-    /**
25
-     * Performs the command handler's logic.
26
-     *
27
-     * @param CommandInterface $command
28
-     * @return mixed
29
-     */
30
-    public function handle(CommandInterface $command);
24
+	/**
25
+	 * Performs the command handler's logic.
26
+	 *
27
+	 * @param CommandInterface $command
28
+	 * @return mixed
29
+	 */
30
+	public function handle(CommandInterface $command);
31 31
 }
Please login to merge, or discard this patch.
core/services/commands/CommandHandlerManagerInterface.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,26 +10,26 @@
 block discarded – undo
10 10
 interface CommandHandlerManagerInterface
11 11
 {
12 12
 
13
-    /**
14
-     * !!! IMPORTANT !!!
15
-     * If overriding the default CommandHandler for a Command,
16
-     * be sure to also override CommandHandler::verify(),
17
-     * or else an Exception will be thrown when the CommandBus
18
-     * attempts to verify that the incoming Command matches the Handler
19
-     *
20
-     * @param CommandHandlerInterface $command_handler
21
-     * @param string $fqcn_for_command Fully Qualified ClassName for Command
22
-     * @return void
23
-     * @throws InvalidCommandHandlerException
24
-     */
25
-    public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = '');
13
+	/**
14
+	 * !!! IMPORTANT !!!
15
+	 * If overriding the default CommandHandler for a Command,
16
+	 * be sure to also override CommandHandler::verify(),
17
+	 * or else an Exception will be thrown when the CommandBus
18
+	 * attempts to verify that the incoming Command matches the Handler
19
+	 *
20
+	 * @param CommandHandlerInterface $command_handler
21
+	 * @param string $fqcn_for_command Fully Qualified ClassName for Command
22
+	 * @return void
23
+	 * @throws InvalidCommandHandlerException
24
+	 */
25
+	public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = '');
26 26
 
27 27
 
28 28
 
29
-    /**
30
-     * @param CommandInterface    $command
31
-     * @param CommandBusInterface $command_bus
32
-     * @return mixed
33
-     */
34
-    public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null);
29
+	/**
30
+	 * @param CommandInterface    $command
31
+	 * @param CommandBusInterface $command_bus
32
+	 * @return mixed
33
+	 */
34
+	public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null);
35 35
 }
Please login to merge, or discard this patch.
core/services/commands/ticket/CancelTicketLineItemCommandHandler.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,36 +23,36 @@
 block discarded – undo
23 23
 {
24 24
 
25 25
 
26
-    /**
27
-     * @var CancelTicketLineItemService $cancel_ticket_line_item_service
28
-     */
29
-    private $cancel_ticket_line_item_service;
30
-
31
-
32
-    /**
33
-     * Command constructor
34
-     *
35
-     * @param CancelTicketLineItemService $cancel_ticket_line_item_service
36
-     */
37
-    public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
38
-    {
39
-        $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
40
-    }
41
-
42
-
43
-    /**
44
-     * @param CommandInterface|CancelTicketLineItemCommand $command
45
-     * @return mixed
46
-     * @throws InvalidEntityException
47
-     * @throws RuntimeException
48
-     */
49
-    public function handle(CommandInterface $command)
50
-    {
51
-        return $this->cancel_ticket_line_item_service->cancel(
52
-            $command->transaction(),
53
-            $command->ticket(),
54
-            $command->quantity(),
55
-            $command->ticketLineItem()
56
-        );
57
-    }
26
+	/**
27
+	 * @var CancelTicketLineItemService $cancel_ticket_line_item_service
28
+	 */
29
+	private $cancel_ticket_line_item_service;
30
+
31
+
32
+	/**
33
+	 * Command constructor
34
+	 *
35
+	 * @param CancelTicketLineItemService $cancel_ticket_line_item_service
36
+	 */
37
+	public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
38
+	{
39
+		$this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
40
+	}
41
+
42
+
43
+	/**
44
+	 * @param CommandInterface|CancelTicketLineItemCommand $command
45
+	 * @return mixed
46
+	 * @throws InvalidEntityException
47
+	 * @throws RuntimeException
48
+	 */
49
+	public function handle(CommandInterface $command)
50
+	{
51
+		return $this->cancel_ticket_line_item_service->cancel(
52
+			$command->transaction(),
53
+			$command->ticket(),
54
+			$command->quantity(),
55
+			$command->ticketLineItem()
56
+		);
57
+	}
58 58
 }
Please login to merge, or discard this patch.