Completed
Branch fix-caching-loader-test (60c3ed)
by
unknown
17:47 queued 10:25
created
core/exceptions/ExceptionLogger.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,18 +33,18 @@
 block discarded – undo
33 33
      */
34 34
     public function log(\Exception $exception, $time = 0)
35 35
     {
36
-        if (! $time) {
36
+        if ( ! $time) {
37 37
             $time = time();
38 38
         }
39 39
         $exception_log = '----------------------------------------------------------------------------------------';
40 40
         $exception_log .= PHP_EOL;
41
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
42
-        $exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL;
43
-        $exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL;
44
-        $exception_log .= 'File: ' . $exception->getFile() . PHP_EOL;
45
-        $exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL;
46
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
47
-        $exception_log .= $exception->getTraceAsString() . PHP_EOL;
41
+        $exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
42
+        $exception_log .= 'Message: '.$exception->getMessage().PHP_EOL;
43
+        $exception_log .= 'Code: '.$exception->getCode().PHP_EOL;
44
+        $exception_log .= 'File: '.$exception->getFile().PHP_EOL;
45
+        $exception_log .= 'Line No: '.$exception->getLine().PHP_EOL;
46
+        $exception_log .= 'Stack trace: '.PHP_EOL;
47
+        $exception_log .= $exception->getTraceAsString().PHP_EOL;
48 48
         $exception_log .= '----------------------------------------------------------------------------------------';
49 49
         $exception_log .= PHP_EOL;
50 50
         error_log($exception_log);
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -12,39 +12,39 @@
 block discarded – undo
12 12
  */
13 13
 class ExceptionLogger
14 14
 {
15
-    /**
16
-     * ExceptionLogger constructor.
17
-     *
18
-     * @param \Exception $exception
19
-     */
20
-    public function __construct(\Exception $exception)
21
-    {
22
-        $this->log($exception);
23
-    }
15
+	/**
16
+	 * ExceptionLogger constructor.
17
+	 *
18
+	 * @param \Exception $exception
19
+	 */
20
+	public function __construct(\Exception $exception)
21
+	{
22
+		$this->log($exception);
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * write exception details to log file
28
-     *
29
-     * @param \Exception $exception
30
-     * @param int        $time
31
-     */
32
-    public function log(\Exception $exception, $time = 0)
33
-    {
34
-        if (! $time) {
35
-            $time = time();
36
-        }
37
-        $exception_log = '----------------------------------------------------------------------------------------';
38
-        $exception_log .= PHP_EOL;
39
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
40
-        $exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL;
41
-        $exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL;
42
-        $exception_log .= 'File: ' . $exception->getFile() . PHP_EOL;
43
-        $exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL;
44
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
45
-        $exception_log .= $exception->getTraceAsString() . PHP_EOL;
46
-        $exception_log .= '----------------------------------------------------------------------------------------';
47
-        $exception_log .= PHP_EOL;
48
-        error_log($exception_log);
49
-    }
26
+	/**
27
+	 * write exception details to log file
28
+	 *
29
+	 * @param \Exception $exception
30
+	 * @param int        $time
31
+	 */
32
+	public function log(\Exception $exception, $time = 0)
33
+	{
34
+		if (! $time) {
35
+			$time = time();
36
+		}
37
+		$exception_log = '----------------------------------------------------------------------------------------';
38
+		$exception_log .= PHP_EOL;
39
+		$exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
40
+		$exception_log .= 'Message: ' . $exception->getMessage() . PHP_EOL;
41
+		$exception_log .= 'Code: ' . $exception->getCode() . PHP_EOL;
42
+		$exception_log .= 'File: ' . $exception->getFile() . PHP_EOL;
43
+		$exception_log .= 'Line No: ' . $exception->getLine() . PHP_EOL;
44
+		$exception_log .= 'Stack trace: ' . PHP_EOL;
45
+		$exception_log .= $exception->getTraceAsString() . PHP_EOL;
46
+		$exception_log .= '----------------------------------------------------------------------------------------';
47
+		$exception_log .= PHP_EOL;
48
+		error_log($exception_log);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
core/services/formatters/FormatterBase.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
24 24
      */
25 25
     public function formatArray($input)
26 26
     {
27
-        if (! is_array($input)) {
27
+        if ( ! is_array($input)) {
28 28
             throw new InvalidDataTypeException('input', $input, 'array');
29 29
         }
30 30
         // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead
31 31
         $formatter = $this;
32 32
         array_walk_recursive(
33 33
             $input,
34
-            function (&$value, $key) use ($formatter) {
34
+            function(&$value, $key) use ($formatter) {
35 35
                 $value = $formatter->format($value);
36 36
             }
37 37
         );
Please login to merge, or discard this patch.
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 FormatterBase implements FormatterInterface
16 16
 {
17
-    /**
18
-     * Recursively applies the formatting to all VALUES in this multi-dimensional array
19
-     *
20
-     * @param array $input
21
-     * @return array
22
-     * @throws InvalidDataTypeException if $input is not an array
23
-     */
24
-    public function formatArray($input)
25
-    {
26
-        if (! is_array($input)) {
27
-            throw new InvalidDataTypeException('input', $input, 'array');
28
-        }
29
-        // we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead
30
-        $formatter = $this;
31
-        array_walk_recursive(
32
-            $input,
33
-            function (&$value, $key) use ($formatter) {
34
-                $value = $formatter->format($value);
35
-            }
36
-        );
37
-        return $input;
38
-    }
17
+	/**
18
+	 * Recursively applies the formatting to all VALUES in this multi-dimensional array
19
+	 *
20
+	 * @param array $input
21
+	 * @return array
22
+	 * @throws InvalidDataTypeException if $input is not an array
23
+	 */
24
+	public function formatArray($input)
25
+	{
26
+		if (! is_array($input)) {
27
+			throw new InvalidDataTypeException('input', $input, 'array');
28
+		}
29
+		// we can use $this inside the closure in PHP 5.3, so pass in a variable pointing to this instead
30
+		$formatter = $this;
31
+		array_walk_recursive(
32
+			$input,
33
+			function (&$value, $key) use ($formatter) {
34
+				$value = $formatter->format($value);
35
+			}
36
+		);
37
+		return $input;
38
+	}
39 39
 }
Please login to merge, or discard this patch.
core/services/request/RequestStackCoreApp.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $this->request = $request;
55 55
         $this->response = $response;
56
-        espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
57
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
56
+        espresso_load_required('EE_Base', EE_CORE.'EE_Base.core.php');
57
+        espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php');
58 58
         // workarounds for PHP < 5.3
59
-        espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php');
59
+        espresso_load_required('EEH_Class_Tools', EE_HELPERS.'EEH_Class_Tools.helper.php');
60 60
         do_action(
61 61
             'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading'
62 62
         );
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     {
84 84
         espresso_load_required(
85 85
             'EE_Bootstrap',
86
-            EE_CORE . 'EE_Bootstrap.core.php'
86
+            EE_CORE.'EE_Bootstrap.core.php'
87 87
         );
88 88
         add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1);
89 89
         add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3);
Please login to merge, or discard this patch.
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -23,92 +23,92 @@
 block discarded – undo
23 23
  */
24 24
 class RequestStackCoreApp implements RequestDecoratorInterface, RequestStackCoreAppInterface
25 25
 {
26
-    /**
27
-     * @var RequestInterface $request
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface $request
28
+	 */
29
+	protected $request;
30 30
 
31
-    /**
32
-     * @var ResponseInterface $response
33
-     */
34
-    protected $response;
31
+	/**
32
+	 * @var ResponseInterface $response
33
+	 */
34
+	protected $response;
35 35
 
36 36
 
37
-    /**
38
-     * handle
39
-     * sets hooks for running rest of system
40
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
41
-     * starting EE Addons from any other point may lead to problems
42
-     *
43
-     * @param RequestInterface  $request
44
-     * @param ResponseInterface $response
45
-     * @return ResponseInterface
46
-     * @throws InvalidClassException
47
-     * @throws EE_Error
48
-     * @throws InvalidDataTypeException
49
-     * @throws InvalidInterfaceException
50
-     * @throws InvalidArgumentException
51
-     */
52
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
53
-    {
54
-        $this->request = $request;
55
-        $this->response = $response;
56
-        espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
57
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
58
-        // workarounds for PHP < 5.3
59
-        espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php');
60
-        do_action(
61
-            'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading'
62
-        );
63
-        // legacy action for backwards compatibility
64
-        do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
65
-        $this->setupFramework();
66
-        $loader = LoaderFactory::getLoader();
67
-        $capabilities_checker = $loader->getShared(
68
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
69
-            [EE_Capabilities::instance()]
70
-        );
71
-        $loader->getShared(
72
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager',
73
-            [$capabilities_checker, $request]
74
-        );
75
-        // WP cron jobs
76
-        $loader->getShared('EE_Cron_Tasks');
77
-        $loader->getShared('EE_System');
78
-        return $this->response;
79
-    }
37
+	/**
38
+	 * handle
39
+	 * sets hooks for running rest of system
40
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
41
+	 * starting EE Addons from any other point may lead to problems
42
+	 *
43
+	 * @param RequestInterface  $request
44
+	 * @param ResponseInterface $response
45
+	 * @return ResponseInterface
46
+	 * @throws InvalidClassException
47
+	 * @throws EE_Error
48
+	 * @throws InvalidDataTypeException
49
+	 * @throws InvalidInterfaceException
50
+	 * @throws InvalidArgumentException
51
+	 */
52
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
53
+	{
54
+		$this->request = $request;
55
+		$this->response = $response;
56
+		espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
57
+		espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
58
+		// workarounds for PHP < 5.3
59
+		espresso_load_required('EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php');
60
+		do_action(
61
+			'EE_EventEspresso_core_services_request_RequestStackCoreApp__handle_request__initialize_core_loading'
62
+		);
63
+		// legacy action for backwards compatibility
64
+		do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
65
+		$this->setupFramework();
66
+		$loader = LoaderFactory::getLoader();
67
+		$capabilities_checker = $loader->getShared(
68
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
69
+			[EE_Capabilities::instance()]
70
+		);
71
+		$loader->getShared(
72
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager',
73
+			[$capabilities_checker, $request]
74
+		);
75
+		// WP cron jobs
76
+		$loader->getShared('EE_Cron_Tasks');
77
+		$loader->getShared('EE_System');
78
+		return $this->response;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * set framework for the rest of EE to hook into when loading
84
-     *
85
-     * @throws EE_Error
86
-     */
87
-    private function setupFramework()
88
-    {
89
-        espresso_load_required(
90
-            'EE_Bootstrap',
91
-            EE_CORE . 'EE_Bootstrap.core.php'
92
-        );
93
-        add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1);
94
-        add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3);
95
-        add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5);
96
-        add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7);
97
-        add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9);
98
-    }
82
+	/**
83
+	 * set framework for the rest of EE to hook into when loading
84
+	 *
85
+	 * @throws EE_Error
86
+	 */
87
+	private function setupFramework()
88
+	{
89
+		espresso_load_required(
90
+			'EE_Bootstrap',
91
+			EE_CORE . 'EE_Bootstrap.core.php'
92
+		);
93
+		add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1);
94
+		add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3);
95
+		add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5);
96
+		add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7);
97
+		add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9);
98
+	}
99 99
 
100 100
 
101
-    /**
102
-     * called after the request stack has been fully processed
103
-     * if any of the middleware apps has requested the plugin be deactivated, then we do that now
104
-     *
105
-     * @param RequestInterface  $request
106
-     * @param ResponseInterface $response
107
-     */
108
-    public function handleResponse(RequestInterface $request, ResponseInterface $response)
109
-    {
110
-        if ($response->pluginDeactivated()) {
111
-            espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
112
-        }
113
-    }
101
+	/**
102
+	 * called after the request stack has been fully processed
103
+	 * if any of the middleware apps has requested the plugin be deactivated, then we do that now
104
+	 *
105
+	 * @param RequestInterface  $request
106
+	 * @param ResponseInterface $response
107
+	 */
108
+	public function handleResponse(RequestInterface $request, ResponseInterface $response)
109
+	{
110
+		if ($response->pluginDeactivated()) {
111
+			espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
112
+		}
113
+	}
114 114
 }
Please login to merge, or discard this patch.
core/services/request/RequestStackBuilder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
109 109
         }
110 110
         // is $middleware_app_class a valid FQCN (or class is already loaded) ?
111
-        if (! class_exists($middleware_app_class)) {
111
+        if ( ! class_exists($middleware_app_class)) {
112 112
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
113 113
         }
114 114
         return $middleware_app;
Please login to merge, or discard this patch.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -19,97 +19,97 @@
 block discarded – undo
19 19
  */
20 20
 class RequestStackBuilder extends SplDoublyLinkedList
21 21
 {
22
-    /**
23
-     * @type LoaderInterface $loader
24
-     */
25
-    private $loader;
22
+	/**
23
+	 * @type LoaderInterface $loader
24
+	 */
25
+	private $loader;
26 26
 
27 27
 
28
-    /**
29
-     * RequestStackBuilder constructor.
30
-     *
31
-     * @param LoaderInterface $loader
32
-     */
33
-    public function __construct(LoaderInterface $loader)
34
-    {
35
-        $this->loader = $loader;
36
-        $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
37
-    }
28
+	/**
29
+	 * RequestStackBuilder constructor.
30
+	 *
31
+	 * @param LoaderInterface $loader
32
+	 */
33
+	public function __construct(LoaderInterface $loader)
34
+	{
35
+		$this->loader = $loader;
36
+		$this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * builds decorated middleware stack
42
-     * by continuously injecting previous middleware app into the next
43
-     *
44
-     * @param RequestStackCoreAppInterface $application
45
-     * @return RequestStack
46
-     * @throws Exception
47
-     */
48
-    public function resolve(RequestStackCoreAppInterface $application)
49
-    {
50
-        $core_app = $application;
51
-        // NOW... because the RequestStack is following the decorator pattern,
52
-        // the first stack app we add will end up at the center of the stack,
53
-        // and will end up being the last item to actually run, but we don't want that!
54
-        // Basically we're dealing with TWO stacks, and transferring items from one to the other,
55
-        // BUT... we want the final stack to be in the same order as the first.
56
-        // So we need to reverse the iterator mode when transferring items,
57
-        // because if we don't, the second stack will end  up in the incorrect order.
58
-        $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
59
-        for ($this->rewind(); $this->valid(); $this->next()) {
60
-            try {
61
-                $middleware_app = $this->validateMiddlewareAppDetails($this->current(), true);
62
-                $middleware_app_class = array_shift($middleware_app);
63
-                $middleware_app_args = is_array($middleware_app) ? $middleware_app : array();
64
-                $middleware_app_args = array($application, $this->loader) + $middleware_app_args;
65
-                $application = $this->loader->getShared($middleware_app_class, $middleware_app_args);
66
-            } catch (InvalidRequestStackMiddlewareException $exception) {
67
-                if (WP_DEBUG) {
68
-                    new ExceptionStackTraceDisplay($exception);
69
-                    continue;
70
-                }
71
-                error_log($exception->getMessage());
72
-            }
73
-        }
74
-        return new RequestStack($application, $core_app);
75
-    }
40
+	/**
41
+	 * builds decorated middleware stack
42
+	 * by continuously injecting previous middleware app into the next
43
+	 *
44
+	 * @param RequestStackCoreAppInterface $application
45
+	 * @return RequestStack
46
+	 * @throws Exception
47
+	 */
48
+	public function resolve(RequestStackCoreAppInterface $application)
49
+	{
50
+		$core_app = $application;
51
+		// NOW... because the RequestStack is following the decorator pattern,
52
+		// the first stack app we add will end up at the center of the stack,
53
+		// and will end up being the last item to actually run, but we don't want that!
54
+		// Basically we're dealing with TWO stacks, and transferring items from one to the other,
55
+		// BUT... we want the final stack to be in the same order as the first.
56
+		// So we need to reverse the iterator mode when transferring items,
57
+		// because if we don't, the second stack will end  up in the incorrect order.
58
+		$this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
59
+		for ($this->rewind(); $this->valid(); $this->next()) {
60
+			try {
61
+				$middleware_app = $this->validateMiddlewareAppDetails($this->current(), true);
62
+				$middleware_app_class = array_shift($middleware_app);
63
+				$middleware_app_args = is_array($middleware_app) ? $middleware_app : array();
64
+				$middleware_app_args = array($application, $this->loader) + $middleware_app_args;
65
+				$application = $this->loader->getShared($middleware_app_class, $middleware_app_args);
66
+			} catch (InvalidRequestStackMiddlewareException $exception) {
67
+				if (WP_DEBUG) {
68
+					new ExceptionStackTraceDisplay($exception);
69
+					continue;
70
+				}
71
+				error_log($exception->getMessage());
72
+			}
73
+		}
74
+		return new RequestStack($application, $core_app);
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * Ensures that the app details that have been pushed onto RequestStackBuilder
80
-     * are all ordered correctly so that the middleware can be properly constructed
81
-     *
82
-     * @param array $middleware_app
83
-     * @param bool  $recurse
84
-     * @return array
85
-     * @throws InvalidRequestStackMiddlewareException
86
-     */
87
-    protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false)
88
-    {
89
-        $middleware_app_class = reset($middleware_app);
90
-        // is array empty ?
91
-        if ($middleware_app_class === false) {
92
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
93
-        }
94
-        // are the class and arguments in the wrong order ?
95
-        if (is_array($middleware_app_class)) {
96
-            if ($recurse === true) {
97
-                return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
98
-            }
99
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
100
-        }
101
-        // is filter callback working like legacy middleware and sending a numerically indexed array ?
102
-        if (is_int($middleware_app_class)) {
103
-            if ($recurse === true) {
104
-                $middleware_app = array_reverse($middleware_app);
105
-                return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
106
-            }
107
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
108
-        }
109
-        // is $middleware_app_class a valid FQCN (or class is already loaded) ?
110
-        if (! class_exists($middleware_app_class)) {
111
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
112
-        }
113
-        return $middleware_app;
114
-    }
78
+	/**
79
+	 * Ensures that the app details that have been pushed onto RequestStackBuilder
80
+	 * are all ordered correctly so that the middleware can be properly constructed
81
+	 *
82
+	 * @param array $middleware_app
83
+	 * @param bool  $recurse
84
+	 * @return array
85
+	 * @throws InvalidRequestStackMiddlewareException
86
+	 */
87
+	protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false)
88
+	{
89
+		$middleware_app_class = reset($middleware_app);
90
+		// is array empty ?
91
+		if ($middleware_app_class === false) {
92
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
93
+		}
94
+		// are the class and arguments in the wrong order ?
95
+		if (is_array($middleware_app_class)) {
96
+			if ($recurse === true) {
97
+				return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
98
+			}
99
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
100
+		}
101
+		// is filter callback working like legacy middleware and sending a numerically indexed array ?
102
+		if (is_int($middleware_app_class)) {
103
+			if ($recurse === true) {
104
+				$middleware_app = array_reverse($middleware_app);
105
+				return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
106
+			}
107
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
108
+		}
109
+		// is $middleware_app_class a valid FQCN (or class is already loaded) ?
110
+		if (! class_exists($middleware_app_class)) {
111
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
112
+		}
113
+		return $middleware_app;
114
+	}
115 115
 }
Please login to merge, or discard this patch.
core/services/request/middleware/Middleware.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
     {
69 69
         $this->request = $request;
70 70
         $this->response = $response;
71
-        if (! $this->response->requestTerminated()) {
71
+        if ( ! $this->response->requestTerminated()) {
72 72
             $this->response = $this->request_stack_app->handleRequest($this->request, $this->response);
73 73
         }
74 74
         return $this->response;
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -25,52 +25,52 @@
 block discarded – undo
25 25
  */
26 26
 abstract class Middleware implements InterminableInterface, RequestDecoratorInterface
27 27
 {
28
-    /**
29
-     * @var RequestDecoratorInterface $request_stack_app
30
-     */
31
-    protected $request_stack_app;
28
+	/**
29
+	 * @var RequestDecoratorInterface $request_stack_app
30
+	 */
31
+	protected $request_stack_app;
32 32
 
33
-    /**
34
-     * @var RequestInterface $request
35
-     */
36
-    protected $request;
33
+	/**
34
+	 * @var RequestInterface $request
35
+	 */
36
+	protected $request;
37 37
 
38
-    /**
39
-     * @var ResponseInterface $response
40
-     */
41
-    protected $response;
38
+	/**
39
+	 * @var ResponseInterface $response
40
+	 */
41
+	protected $response;
42 42
 
43
-    /**
44
-     * @var LoaderInterface
45
-     */
46
-    protected $loader;
43
+	/**
44
+	 * @var LoaderInterface
45
+	 */
46
+	protected $loader;
47 47
 
48 48
 
49
-    /**
50
-     * @param RequestDecoratorInterface $request_stack_app
51
-     * @param LoaderInterface           $loader
52
-     */
53
-    public function __construct(RequestDecoratorInterface $request_stack_app, LoaderInterface $loader)
54
-    {
55
-        $this->request_stack_app = $request_stack_app;
56
-        $this->loader = $loader;
57
-    }
49
+	/**
50
+	 * @param RequestDecoratorInterface $request_stack_app
51
+	 * @param LoaderInterface           $loader
52
+	 */
53
+	public function __construct(RequestDecoratorInterface $request_stack_app, LoaderInterface $loader)
54
+	{
55
+		$this->request_stack_app = $request_stack_app;
56
+		$this->loader = $loader;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * process_request_stack
62
-     *
63
-     * @param RequestInterface  $request
64
-     * @param ResponseInterface $response
65
-     * @return ResponseInterface
66
-     */
67
-    protected function processRequestStack(RequestInterface $request, ResponseInterface $response)
68
-    {
69
-        $this->request = $request;
70
-        $this->response = $response;
71
-        if (! $this->response->requestTerminated()) {
72
-            $this->response = $this->request_stack_app->handleRequest($this->request, $this->response);
73
-        }
74
-        return $this->response;
75
-    }
60
+	/**
61
+	 * process_request_stack
62
+	 *
63
+	 * @param RequestInterface  $request
64
+	 * @param ResponseInterface $response
65
+	 * @return ResponseInterface
66
+	 */
67
+	protected function processRequestStack(RequestInterface $request, ResponseInterface $response)
68
+	{
69
+		$this->request = $request;
70
+		$this->response = $response;
71
+		if (! $this->response->requestTerminated()) {
72
+			$this->response = $this->request_stack_app->handleRequest($this->request, $this->response);
73
+		}
74
+		return $this->response;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
core/services/notices/AdminNotice.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function __construct(NoticeInterface $notice, $display_now = true)
41 41
     {
42 42
         $this->notice = $notice;
43
-        if (! did_action('admin_notices')) {
43
+        if ( ! did_action('admin_notices')) {
44 44
             add_action('admin_notices', array($this, 'displayNotice'));
45 45
         } elseif ($display_now) {
46 46
             $this->displayNotice();
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     {
109 109
         $message = $this->notice->message();
110 110
         if (WP_DEBUG && $this->getType() === AdminNotice::ERROR) {
111
-            $message .= '<br/><span class="tiny-text">' . $this->generateErrorCode() . '</span>';
111
+            $message .= '<br/><span class="tiny-text">'.$this->generateErrorCode().'</span>';
112 112
         }
113 113
         return $message;
114 114
     }
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $file = explode('.', basename($this->notice->file()));
126 126
         $error_code = ! empty($file[0]) ? $file[0] : '';
127
-        $error_code .= ! empty($error_code) ? ' - ' . $this->notice->func() : $this->notice->func();
128
-        $error_code .= ' - ' . $this->notice->line();
127
+        $error_code .= ! empty($error_code) ? ' - '.$this->notice->func() : $this->notice->func();
128
+        $error_code .= ' - '.$this->notice->line();
129 129
         return $error_code;
130 130
     }
131 131
 }
Please login to merge, or discard this patch.
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -14,115 +14,115 @@
 block discarded – undo
14 14
  */
15 15
 class AdminNotice
16 16
 {
17
-    const ERROR = 'notice-error';
18
-
19
-    const WARNING = 'notice-warning';
20
-
21
-    const SUCCESS = 'notice-success';
22
-
23
-    const INFORMATION = 'notice-info';
24
-
25
-    const DISMISSABLE = ' is-dismissible';
26
-
27
-    /**
28
-     * generic system notice to be converted into a WP admin notice
29
-     *
30
-     * @var NoticeInterface $notice
31
-     */
32
-    private $notice;
33
-
34
-
35
-    /**
36
-     * AdminNotice constructor.
37
-     *
38
-     * @param NoticeInterface $notice
39
-     * @param bool            $display_now
40
-     */
41
-    public function __construct(NoticeInterface $notice, $display_now = true)
42
-    {
43
-        $this->notice = $notice;
44
-        if (! did_action('admin_notices')) {
45
-            add_action('admin_notices', array($this, 'displayNotice'));
46
-        } elseif ($display_now) {
47
-            $this->displayNotice();
48
-        }
49
-    }
50
-
51
-
52
-    /**
53
-     * @return void
54
-     */
55
-    public function displayNotice()
56
-    {
57
-        echo wp_kses($this->getNotice(), AllowedTags::getAllowedTags());
58
-    }
59
-
60
-
61
-    /**
62
-     * produces something  like:
63
-     *  <div class="notice notice-success is-dismissible event-espresso-admin-notice">
64
-     *      <p>YOU DID IT!</p>
65
-     *      <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this
66
-     *      notice.</span></button>
67
-     *  </div>
68
-     *
69
-     * @return string
70
-     */
71
-    public function getNotice()
72
-    {
73
-        return sprintf(
74
-            '<div class="notice %1$s%2$s event-espresso-admin-notice"><p>%3$s</p></div>',
75
-            $this->getType(),
76
-            $this->notice->isDismissible() ? AdminNotice::DISMISSABLE : '',
77
-            $this->getMessage()
78
-        );
79
-    }
80
-
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    private function getType()
86
-    {
87
-        switch ($this->notice->type()) {
88
-            case Notice::ERROR:
89
-                return AdminNotice::ERROR;
90
-            case Notice::ATTENTION:
91
-                return AdminNotice::WARNING;
92
-            case Notice::SUCCESS:
93
-                return AdminNotice::SUCCESS;
94
-            case Notice::INFORMATION:
95
-            default:
96
-                return AdminNotice::INFORMATION;
97
-        }
98
-    }
99
-
100
-
101
-    /**
102
-     * @return string
103
-     */
104
-    protected function getMessage()
105
-    {
106
-        $message = $this->notice->message();
107
-        if (WP_DEBUG && $this->getType() === AdminNotice::ERROR) {
108
-            $message .= '<br/><span class="tiny-text">' . $this->generateErrorCode() . '</span>';
109
-        }
110
-        return $message;
111
-    }
112
-
113
-
114
-    /**
115
-     * create error code from filepath, function name,
116
-     * and line number where notice was generated
117
-     *
118
-     * @return string
119
-     */
120
-    protected function generateErrorCode()
121
-    {
122
-        $file = explode('.', basename($this->notice->file()));
123
-        $error_code = ! empty($file[0]) ? $file[0] : '';
124
-        $error_code .= ! empty($error_code) ? ' - ' . $this->notice->func() : $this->notice->func();
125
-        $error_code .= ' - ' . $this->notice->line();
126
-        return $error_code;
127
-    }
17
+	const ERROR = 'notice-error';
18
+
19
+	const WARNING = 'notice-warning';
20
+
21
+	const SUCCESS = 'notice-success';
22
+
23
+	const INFORMATION = 'notice-info';
24
+
25
+	const DISMISSABLE = ' is-dismissible';
26
+
27
+	/**
28
+	 * generic system notice to be converted into a WP admin notice
29
+	 *
30
+	 * @var NoticeInterface $notice
31
+	 */
32
+	private $notice;
33
+
34
+
35
+	/**
36
+	 * AdminNotice constructor.
37
+	 *
38
+	 * @param NoticeInterface $notice
39
+	 * @param bool            $display_now
40
+	 */
41
+	public function __construct(NoticeInterface $notice, $display_now = true)
42
+	{
43
+		$this->notice = $notice;
44
+		if (! did_action('admin_notices')) {
45
+			add_action('admin_notices', array($this, 'displayNotice'));
46
+		} elseif ($display_now) {
47
+			$this->displayNotice();
48
+		}
49
+	}
50
+
51
+
52
+	/**
53
+	 * @return void
54
+	 */
55
+	public function displayNotice()
56
+	{
57
+		echo wp_kses($this->getNotice(), AllowedTags::getAllowedTags());
58
+	}
59
+
60
+
61
+	/**
62
+	 * produces something  like:
63
+	 *  <div class="notice notice-success is-dismissible event-espresso-admin-notice">
64
+	 *      <p>YOU DID IT!</p>
65
+	 *      <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this
66
+	 *      notice.</span></button>
67
+	 *  </div>
68
+	 *
69
+	 * @return string
70
+	 */
71
+	public function getNotice()
72
+	{
73
+		return sprintf(
74
+			'<div class="notice %1$s%2$s event-espresso-admin-notice"><p>%3$s</p></div>',
75
+			$this->getType(),
76
+			$this->notice->isDismissible() ? AdminNotice::DISMISSABLE : '',
77
+			$this->getMessage()
78
+		);
79
+	}
80
+
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	private function getType()
86
+	{
87
+		switch ($this->notice->type()) {
88
+			case Notice::ERROR:
89
+				return AdminNotice::ERROR;
90
+			case Notice::ATTENTION:
91
+				return AdminNotice::WARNING;
92
+			case Notice::SUCCESS:
93
+				return AdminNotice::SUCCESS;
94
+			case Notice::INFORMATION:
95
+			default:
96
+				return AdminNotice::INFORMATION;
97
+		}
98
+	}
99
+
100
+
101
+	/**
102
+	 * @return string
103
+	 */
104
+	protected function getMessage()
105
+	{
106
+		$message = $this->notice->message();
107
+		if (WP_DEBUG && $this->getType() === AdminNotice::ERROR) {
108
+			$message .= '<br/><span class="tiny-text">' . $this->generateErrorCode() . '</span>';
109
+		}
110
+		return $message;
111
+	}
112
+
113
+
114
+	/**
115
+	 * create error code from filepath, function name,
116
+	 * and line number where notice was generated
117
+	 *
118
+	 * @return string
119
+	 */
120
+	protected function generateErrorCode()
121
+	{
122
+		$file = explode('.', basename($this->notice->file()));
123
+		$error_code = ! empty($file[0]) ? $file[0] : '';
124
+		$error_code .= ! empty($error_code) ? ' - ' . $this->notice->func() : $this->notice->func();
125
+		$error_code .= ' - ' . $this->notice->line();
126
+		return $error_code;
127
+	}
128 128
 }
Please login to merge, or discard this patch.
core/services/container/NewCoffeeMaker.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             case 'new_instance':
45 45
             case 'new_instance_from_db':
46 46
                 $injector = $this->injector();
47
-                $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) {
47
+                $closure = function($arguments) use ($recipe, $reflector, $method, $injector) {
48 48
                     return call_user_func_array(
49 49
                         array($reflector->getName(), $method),
50 50
                         $injector->resolveDependencies($recipe, $reflector, $arguments)
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
                 };
53 53
                 break;
54 54
             case 'newInstance':
55
-                $closure = function () use ($reflector) {
55
+                $closure = function() use ($reflector) {
56 56
                     return $reflector->newInstance();
57 57
                 };
58 58
                 break;
59 59
             case 'newInstanceArgs':
60 60
             default:
61 61
                 $injector = $this->injector();
62
-                $closure = function ($arguments) use ($recipe, $reflector, $injector) {
62
+                $closure = function($arguments) use ($recipe, $reflector, $injector) {
63 63
                     return $reflector->newInstanceArgs(
64 64
                         $injector->resolveDependencies($recipe, $reflector, $arguments)
65 65
                     );
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,51 +18,51 @@
 block discarded – undo
18 18
  */
19 19
 class NewCoffeeMaker extends CoffeeMaker
20 20
 {
21
-    /**
22
-     * @return string
23
-     */
24
-    public function type()
25
-    {
26
-        return CoffeeMaker::BREW_NEW;
27
-    }
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function type()
25
+	{
26
+		return CoffeeMaker::BREW_NEW;
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @param RecipeInterface $recipe
32
-     * @param array           $arguments
33
-     * @return mixed
34
-     */
35
-    public function brew(RecipeInterface $recipe, $arguments = array())
36
-    {
37
-        $this->resolveClassAndFilepath($recipe);
38
-        $reflector = $this->injector()->getReflectionClass($recipe->fqcn());
39
-        $method = $this->resolveInstantiationMethod($reflector);
40
-        switch ($method) {
41
-            case 'instance':
42
-            case 'new_instance':
43
-            case 'new_instance_from_db':
44
-                $injector = $this->injector();
45
-                $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) {
46
-                    return call_user_func_array(
47
-                        array($reflector->getName(), $method),
48
-                        $injector->resolveDependencies($recipe, $reflector, $arguments)
49
-                    );
50
-                };
51
-                break;
52
-            case 'newInstance':
53
-                $closure = function () use ($reflector) {
54
-                    return $reflector->newInstance();
55
-                };
56
-                break;
57
-            case 'newInstanceArgs':
58
-            default:
59
-                $injector = $this->injector();
60
-                $closure = function ($arguments) use ($recipe, $reflector, $injector) {
61
-                    return $reflector->newInstanceArgs(
62
-                        $injector->resolveDependencies($recipe, $reflector, $arguments)
63
-                    );
64
-                };
65
-        }
66
-        return $this->coffeePot()->addClosure($recipe->identifier(), $closure);
67
-    }
30
+	/**
31
+	 * @param RecipeInterface $recipe
32
+	 * @param array           $arguments
33
+	 * @return mixed
34
+	 */
35
+	public function brew(RecipeInterface $recipe, $arguments = array())
36
+	{
37
+		$this->resolveClassAndFilepath($recipe);
38
+		$reflector = $this->injector()->getReflectionClass($recipe->fqcn());
39
+		$method = $this->resolveInstantiationMethod($reflector);
40
+		switch ($method) {
41
+			case 'instance':
42
+			case 'new_instance':
43
+			case 'new_instance_from_db':
44
+				$injector = $this->injector();
45
+				$closure = function ($arguments) use ($recipe, $reflector, $method, $injector) {
46
+					return call_user_func_array(
47
+						array($reflector->getName(), $method),
48
+						$injector->resolveDependencies($recipe, $reflector, $arguments)
49
+					);
50
+				};
51
+				break;
52
+			case 'newInstance':
53
+				$closure = function () use ($reflector) {
54
+					return $reflector->newInstance();
55
+				};
56
+				break;
57
+			case 'newInstanceArgs':
58
+			default:
59
+				$injector = $this->injector();
60
+				$closure = function ($arguments) use ($recipe, $reflector, $injector) {
61
+					return $reflector->newInstanceArgs(
62
+						$injector->resolveDependencies($recipe, $reflector, $arguments)
63
+					);
64
+				};
65
+		}
66
+		return $this->coffeePot()->addClosure($recipe->identifier(), $closure);
67
+	}
68 68
 }
Please login to merge, or discard this patch.
core/services/commands/registration/CreateRegistrationCommand.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     ) {
80 80
         // grab the related ticket object for this line_item
81 81
         $this->ticket = $ticket_line_item->ticket();
82
-        if (! $this->ticket instanceof EE_Ticket) {
82
+        if ( ! $this->ticket instanceof EE_Ticket) {
83 83
             throw new InvalidEntityException(
84 84
                 is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85 85
                 'EE_Ticket',
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function getCapCheck()
105 105
     {
106
-        if (! $this->cap_check instanceof CapCheckInterface) {
106
+        if ( ! $this->cap_check instanceof CapCheckInterface) {
107 107
             return new CapCheck('ee_edit_registrations', 'create_new_registration');
108 108
         }
109 109
         return $this->cap_check;
Please login to merge, or discard this patch.
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -24,151 +24,151 @@
 block discarded – undo
24 24
  */
25 25
 class CreateRegistrationCommand extends Command implements CommandRequiresCapCheckInterface
26 26
 {
27
-    /**
28
-     * @var EE_Transaction $transaction
29
-     */
30
-    private $transaction;
31
-
32
-    /**
33
-     * @var EE_Ticket $ticket
34
-     */
35
-    private $ticket;
36
-
37
-    /**
38
-     * @var EE_Line_Item $ticket_line_item
39
-     */
40
-    private $ticket_line_item;
41
-
42
-    /**
43
-     * @var int $reg_count
44
-     */
45
-    private $reg_count;
46
-
47
-    /**
48
-     * @var int $reg_group_size
49
-     */
50
-    private $reg_group_size;
51
-
52
-    /**
53
-     * @var string $reg_status
54
-     */
55
-    private $reg_status;
56
-
57
-    /**
58
-     * @var EE_Registration $registration
59
-     */
60
-    protected $registration;
61
-
62
-
63
-    /**
64
-     * CreateRegistrationCommand constructor.
65
-     *
66
-     * @param EE_Transaction $transaction
67
-     * @param EE_Line_Item   $ticket_line_item
68
-     * @param int            $reg_count
69
-     * @param int            $reg_group_size
70
-     * @param string         $reg_status
71
-     * @throws InvalidEntityException
72
-     */
73
-    public function __construct(
74
-        EE_Transaction $transaction,
75
-        EE_Line_Item $ticket_line_item,
76
-        $reg_count = 1,
77
-        $reg_group_size = 0,
78
-        $reg_status = EEM_Registration::status_id_incomplete
79
-    ) {
80
-        // grab the related ticket object for this line_item
81
-        $this->ticket = $ticket_line_item->ticket();
82
-        if (! $this->ticket instanceof EE_Ticket) {
83
-            throw new InvalidEntityException(
84
-                is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85
-                'EE_Ticket',
86
-                sprintf(
87
-                    esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'),
88
-                    $ticket_line_item->ID()
89
-                )
90
-            );
91
-        }
92
-        $this->transaction = $transaction;
93
-        $this->ticket_line_item = $ticket_line_item;
94
-        $this->reg_count = absint($reg_count);
95
-        $this->reg_group_size = absint($reg_group_size);
96
-        $this->reg_status = $reg_status;
97
-    }
98
-
99
-
100
-    /**
101
-     * @return CapCheckInterface
102
-     * @throws InvalidDataTypeException
103
-     */
104
-    public function getCapCheck()
105
-    {
106
-        if (! $this->cap_check instanceof CapCheckInterface) {
107
-            return new CapCheck('ee_edit_registrations', 'create_new_registration');
108
-        }
109
-        return $this->cap_check;
110
-    }
111
-
112
-
113
-    /**
114
-     * @return EE_Transaction
115
-     */
116
-    public function transaction()
117
-    {
118
-        return $this->transaction;
119
-    }
120
-
121
-
122
-    /**
123
-     * @return EE_Ticket
124
-     */
125
-    public function ticket()
126
-    {
127
-        return $this->ticket;
128
-    }
129
-
130
-
131
-    /**
132
-     * @return EE_Line_Item
133
-     */
134
-    public function ticketLineItem()
135
-    {
136
-        return $this->ticket_line_item;
137
-    }
138
-
139
-
140
-    /**
141
-     * @return int
142
-     */
143
-    public function regCount()
144
-    {
145
-        return $this->reg_count;
146
-    }
147
-
148
-
149
-    /**
150
-     * @return int
151
-     */
152
-    public function regGroupSize()
153
-    {
154
-        return $this->reg_group_size;
155
-    }
156
-
157
-
158
-    /**
159
-     * @return string
160
-     */
161
-    public function regStatus()
162
-    {
163
-        return $this->reg_status;
164
-    }
165
-
166
-
167
-    /**
168
-     * @return EE_Registration
169
-     */
170
-    public function registration()
171
-    {
172
-        return $this->registration;
173
-    }
27
+	/**
28
+	 * @var EE_Transaction $transaction
29
+	 */
30
+	private $transaction;
31
+
32
+	/**
33
+	 * @var EE_Ticket $ticket
34
+	 */
35
+	private $ticket;
36
+
37
+	/**
38
+	 * @var EE_Line_Item $ticket_line_item
39
+	 */
40
+	private $ticket_line_item;
41
+
42
+	/**
43
+	 * @var int $reg_count
44
+	 */
45
+	private $reg_count;
46
+
47
+	/**
48
+	 * @var int $reg_group_size
49
+	 */
50
+	private $reg_group_size;
51
+
52
+	/**
53
+	 * @var string $reg_status
54
+	 */
55
+	private $reg_status;
56
+
57
+	/**
58
+	 * @var EE_Registration $registration
59
+	 */
60
+	protected $registration;
61
+
62
+
63
+	/**
64
+	 * CreateRegistrationCommand constructor.
65
+	 *
66
+	 * @param EE_Transaction $transaction
67
+	 * @param EE_Line_Item   $ticket_line_item
68
+	 * @param int            $reg_count
69
+	 * @param int            $reg_group_size
70
+	 * @param string         $reg_status
71
+	 * @throws InvalidEntityException
72
+	 */
73
+	public function __construct(
74
+		EE_Transaction $transaction,
75
+		EE_Line_Item $ticket_line_item,
76
+		$reg_count = 1,
77
+		$reg_group_size = 0,
78
+		$reg_status = EEM_Registration::status_id_incomplete
79
+	) {
80
+		// grab the related ticket object for this line_item
81
+		$this->ticket = $ticket_line_item->ticket();
82
+		if (! $this->ticket instanceof EE_Ticket) {
83
+			throw new InvalidEntityException(
84
+				is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85
+				'EE_Ticket',
86
+				sprintf(
87
+					esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'),
88
+					$ticket_line_item->ID()
89
+				)
90
+			);
91
+		}
92
+		$this->transaction = $transaction;
93
+		$this->ticket_line_item = $ticket_line_item;
94
+		$this->reg_count = absint($reg_count);
95
+		$this->reg_group_size = absint($reg_group_size);
96
+		$this->reg_status = $reg_status;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return CapCheckInterface
102
+	 * @throws InvalidDataTypeException
103
+	 */
104
+	public function getCapCheck()
105
+	{
106
+		if (! $this->cap_check instanceof CapCheckInterface) {
107
+			return new CapCheck('ee_edit_registrations', 'create_new_registration');
108
+		}
109
+		return $this->cap_check;
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return EE_Transaction
115
+	 */
116
+	public function transaction()
117
+	{
118
+		return $this->transaction;
119
+	}
120
+
121
+
122
+	/**
123
+	 * @return EE_Ticket
124
+	 */
125
+	public function ticket()
126
+	{
127
+		return $this->ticket;
128
+	}
129
+
130
+
131
+	/**
132
+	 * @return EE_Line_Item
133
+	 */
134
+	public function ticketLineItem()
135
+	{
136
+		return $this->ticket_line_item;
137
+	}
138
+
139
+
140
+	/**
141
+	 * @return int
142
+	 */
143
+	public function regCount()
144
+	{
145
+		return $this->reg_count;
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return int
151
+	 */
152
+	public function regGroupSize()
153
+	{
154
+		return $this->reg_group_size;
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return string
160
+	 */
161
+	public function regStatus()
162
+	{
163
+		return $this->reg_status;
164
+	}
165
+
166
+
167
+	/**
168
+	 * @return EE_Registration
169
+	 */
170
+	public function registration()
171
+	{
172
+		return $this->registration;
173
+	}
174 174
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/rpc/Checkin.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             $force = false;
57 57
         }
58 58
         $reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
59
-        if (! $reg instanceof EE_Registration) {
59
+        if ( ! $reg instanceof EE_Registration) {
60 60
             return $this->sendResponse(
61 61
                 new WP_Error(
62 62
                     'rest_registration_toggle_checkin_invalid_id',
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                 )
72 72
             );
73 73
         }
74
-        if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) {
74
+        if ( ! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) {
75 75
             return $this->sendResponse(
76 76
                 new WP_Error(
77 77
                     'rest_user_cannot_toggle_checkin',
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $success = $reg->toggle_checkin_status($dtt_id, ! $force);
87 87
         if ($success === false) {
88 88
             // check if we know they can't check in because they're not approved and we aren't forcing
89
-            if (! $reg->is_approved() && ! $force) {
89
+            if ( ! $reg->is_approved() && ! $force) {
90 90
                 // rely on EE_Error::add_error messages to have been added to give more data about why it failed
91 91
                 return $this->sendResponse(
92 92
                     new WP_Error(
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 ),
119 119
             )
120 120
         );
121
-        if (! $checkin instanceof EE_Checkin) {
121
+        if ( ! $checkin instanceof EE_Checkin) {
122 122
             return $this->sendResponse(
123 123
                 new WP_Error(
124 124
                     'rest_toggle_checkin_error',
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         }
138 138
         $get_request = new WP_REST_Request(
139 139
             'GET',
140
-            '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID()
140
+            '/'.EED_Core_Rest_Api::ee_api_namespace.'v'.$version.'/checkins/'.$checkin->ID()
141 141
         );
142 142
         $get_request->set_url_params(
143 143
             array(
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -25,124 +25,124 @@
 block discarded – undo
25 25
  */
26 26
 class Checkin extends Base
27 27
 {
28
-    /**
29
-     * @param WP_REST_Request $request
30
-     * @param string          $version
31
-     * @return WP_Error|WP_REST_Response
32
-     */
33
-    public static function handleRequestToggleCheckin(WP_REST_Request $request, $version)
34
-    {
35
-        $controller = new Checkin();
36
-        return $controller->createCheckinCheckoutObject($request, $version);
37
-    }
28
+	/**
29
+	 * @param WP_REST_Request $request
30
+	 * @param string          $version
31
+	 * @return WP_Error|WP_REST_Response
32
+	 */
33
+	public static function handleRequestToggleCheckin(WP_REST_Request $request, $version)
34
+	{
35
+		$controller = new Checkin();
36
+		return $controller->createCheckinCheckoutObject($request, $version);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Toggles whether the user is checked in or not.
42
-     *
43
-     * @param WP_REST_Request $request
44
-     * @param string          $version
45
-     * @return WP_Error|WP_REST_Response
46
-     */
47
-    protected function createCheckinCheckoutObject(WP_REST_Request $request, $version)
48
-    {
49
-        $reg_id = $request->get_param('REG_ID');
50
-        $dtt_id = $request->get_param('DTT_ID');
51
-        $force = $request->get_param('force');
52
-        if ($force == 'true') {
53
-            $force = true;
54
-        } else {
55
-            $force = false;
56
-        }
57
-        $reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
58
-        if (! $reg instanceof EE_Registration) {
59
-            return $this->sendResponse(
60
-                new WP_Error(
61
-                    'rest_registration_toggle_checkin_invalid_id',
62
-                    sprintf(
63
-                        esc_html__(
64
-                            'You cannot checkin registration with ID %1$s because it doesn\'t exist.',
65
-                            'event_espresso'
66
-                        ),
67
-                        $reg_id
68
-                    ),
69
-                    array('status' => 422)
70
-                )
71
-            );
72
-        }
73
-        if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) {
74
-            return $this->sendResponse(
75
-                new WP_Error(
76
-                    'rest_user_cannot_toggle_checkin',
77
-                    sprintf(
78
-                        esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'),
79
-                        $reg_id
80
-                    ),
81
-                    array('status' => 403)
82
-                )
83
-            );
84
-        }
85
-        $success = $reg->toggle_checkin_status($dtt_id, ! $force);
86
-        if ($success === false) {
87
-            // check if we know they can't check in because they're not approved and we aren't forcing
88
-            if (! $reg->is_approved() && ! $force) {
89
-                // rely on EE_Error::add_error messages to have been added to give more data about why it failed
90
-                return $this->sendResponse(
91
-                    new WP_Error(
92
-                        'rest_toggle_checkin_failed',
93
-                        esc_html__(
94
-                        // @codingStandardsIgnoreStart
95
-                            'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.',
96
-                            // @codingStandardsIgnoreEnd
97
-                            'event_espresso'
98
-                        )
99
-                    )
100
-                );
101
-            }
102
-            return $this->sendResponse(
103
-                new WP_Error(
104
-                    'rest_toggle_checkin_failed_not_forceable',
105
-                    esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso')
106
-                )
107
-            );
108
-        }
109
-        $checkin = EEM_Checkin::instance()->get_one(
110
-            array(
111
-                array(
112
-                    'REG_ID' => $reg_id,
113
-                    'DTT_ID' => $dtt_id,
114
-                ),
115
-                'order_by' => array(
116
-                    'CHK_timestamp' => 'DESC',
117
-                ),
118
-            )
119
-        );
120
-        if (! $checkin instanceof EE_Checkin) {
121
-            return $this->sendResponse(
122
-                new WP_Error(
123
-                    'rest_toggle_checkin_error',
124
-                    sprintf(
125
-                        esc_html__(
126
-                        // @codingStandardsIgnoreStart
127
-                            'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.',
128
-                            // @codingStandardsIgnoreEnd
129
-                            'event_espresso'
130
-                        ),
131
-                        $reg_id,
132
-                        $dtt_id
133
-                    )
134
-                )
135
-            );
136
-        }
137
-        $get_request = new WP_REST_Request(
138
-            'GET',
139
-            '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID()
140
-        );
141
-        $get_request->set_url_params(
142
-            array(
143
-                'id' => $checkin->ID(),
144
-            )
145
-        );
146
-        return Read::handleRequestGetOne($get_request, $version, 'Checkin');
147
-    }
40
+	/**
41
+	 * Toggles whether the user is checked in or not.
42
+	 *
43
+	 * @param WP_REST_Request $request
44
+	 * @param string          $version
45
+	 * @return WP_Error|WP_REST_Response
46
+	 */
47
+	protected function createCheckinCheckoutObject(WP_REST_Request $request, $version)
48
+	{
49
+		$reg_id = $request->get_param('REG_ID');
50
+		$dtt_id = $request->get_param('DTT_ID');
51
+		$force = $request->get_param('force');
52
+		if ($force == 'true') {
53
+			$force = true;
54
+		} else {
55
+			$force = false;
56
+		}
57
+		$reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
58
+		if (! $reg instanceof EE_Registration) {
59
+			return $this->sendResponse(
60
+				new WP_Error(
61
+					'rest_registration_toggle_checkin_invalid_id',
62
+					sprintf(
63
+						esc_html__(
64
+							'You cannot checkin registration with ID %1$s because it doesn\'t exist.',
65
+							'event_espresso'
66
+						),
67
+						$reg_id
68
+					),
69
+					array('status' => 422)
70
+				)
71
+			);
72
+		}
73
+		if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) {
74
+			return $this->sendResponse(
75
+				new WP_Error(
76
+					'rest_user_cannot_toggle_checkin',
77
+					sprintf(
78
+						esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'),
79
+						$reg_id
80
+					),
81
+					array('status' => 403)
82
+				)
83
+			);
84
+		}
85
+		$success = $reg->toggle_checkin_status($dtt_id, ! $force);
86
+		if ($success === false) {
87
+			// check if we know they can't check in because they're not approved and we aren't forcing
88
+			if (! $reg->is_approved() && ! $force) {
89
+				// rely on EE_Error::add_error messages to have been added to give more data about why it failed
90
+				return $this->sendResponse(
91
+					new WP_Error(
92
+						'rest_toggle_checkin_failed',
93
+						esc_html__(
94
+						// @codingStandardsIgnoreStart
95
+							'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.',
96
+							// @codingStandardsIgnoreEnd
97
+							'event_espresso'
98
+						)
99
+					)
100
+				);
101
+			}
102
+			return $this->sendResponse(
103
+				new WP_Error(
104
+					'rest_toggle_checkin_failed_not_forceable',
105
+					esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso')
106
+				)
107
+			);
108
+		}
109
+		$checkin = EEM_Checkin::instance()->get_one(
110
+			array(
111
+				array(
112
+					'REG_ID' => $reg_id,
113
+					'DTT_ID' => $dtt_id,
114
+				),
115
+				'order_by' => array(
116
+					'CHK_timestamp' => 'DESC',
117
+				),
118
+			)
119
+		);
120
+		if (! $checkin instanceof EE_Checkin) {
121
+			return $this->sendResponse(
122
+				new WP_Error(
123
+					'rest_toggle_checkin_error',
124
+					sprintf(
125
+						esc_html__(
126
+						// @codingStandardsIgnoreStart
127
+							'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.',
128
+							// @codingStandardsIgnoreEnd
129
+							'event_espresso'
130
+						),
131
+						$reg_id,
132
+						$dtt_id
133
+					)
134
+				)
135
+			);
136
+		}
137
+		$get_request = new WP_REST_Request(
138
+			'GET',
139
+			'/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID()
140
+		);
141
+		$get_request->set_url_params(
142
+			array(
143
+				'id' => $checkin->ID(),
144
+			)
145
+		);
146
+		return Read::handleRequestGetOne($get_request, $version, 'Checkin');
147
+	}
148 148
 }
Please login to merge, or discard this patch.