@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * |
@@ -65,35 +65,35 @@ discard block |
||
65 | 65 | * @param EE_Response $response |
66 | 66 | * @return EE_Response |
67 | 67 | */ |
68 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
68 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
69 | 69 | $this->request = $request; |
70 | 70 | $this->response = $response; |
71 | 71 | // info about how to load classes required by other classes |
72 | 72 | $this->dependency_map = $this->_load_dependency_map(); |
73 | 73 | // central repository for classes |
74 | 74 | $this->registry = $this->_load_registry(); |
75 | - do_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading' ); |
|
75 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
76 | 76 | // PSR4 Autoloaders |
77 | - $this->registry->load_core( 'EE_Psr4AutoloaderInit' ); |
|
77 | + $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
78 | 78 | // create and cache the CommandBus, and also add the CapChecker middleware |
79 | 79 | $this->registry->create( |
80 | 80 | 'CommandBusInterface', |
81 | 81 | array( |
82 | 82 | null, |
83 | - $this->registry->create( 'CapChecker' ) |
|
83 | + $this->registry->create('CapChecker') |
|
84 | 84 | ), |
85 | 85 | true |
86 | 86 | ); |
87 | 87 | // workarounds for PHP < 5.3 |
88 | 88 | $this->_load_class_tools(); |
89 | 89 | // load interfaces |
90 | - espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' ); |
|
90 | + espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
91 | 91 | // deprecated functions |
92 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
92 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
93 | 93 | // WP cron jobs |
94 | - $this->registry->load_core( 'Cron_Tasks' ); |
|
95 | - $this->registry->load_core( 'EE_Request_Handler' ); |
|
96 | - $this->registry->load_core( 'EE_System' ); |
|
94 | + $this->registry->load_core('Cron_Tasks'); |
|
95 | + $this->registry->load_core('EE_Request_Handler'); |
|
96 | + $this->registry->load_core('EE_System'); |
|
97 | 97 | |
98 | 98 | return $this->response; |
99 | 99 | } |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | * @throws \EE_Error |
124 | 124 | */ |
125 | 125 | public function dependency_map() { |
126 | - if ( ! $this->dependency_map instanceof EE_Dependency_Map ) { |
|
126 | + if ( ! $this->dependency_map instanceof EE_Dependency_Map) { |
|
127 | 127 | throw new EE_Error( |
128 | 128 | sprintf( |
129 | - __( 'Invalid EE_Dependency_Map: "%1$s"', 'event_espresso' ), |
|
130 | - print_r( $this->dependency_map, true ) |
|
129 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
130 | + print_r($this->dependency_map, true) |
|
131 | 131 | ) |
132 | 132 | ); |
133 | 133 | } |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | 143 | public function registry() { |
144 | - if ( ! $this->registry instanceof EE_Registry ) { |
|
144 | + if ( ! $this->registry instanceof EE_Registry) { |
|
145 | 145 | throw new EE_Error( |
146 | 146 | sprintf( |
147 | - __( 'Invalid EE_Registry: "%1$s"', 'event_espresso' ), |
|
148 | - print_r( $this->registry, true ) |
|
147 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
148 | + print_r($this->registry, true) |
|
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | } |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | * @return EE_Dependency_Map |
162 | 162 | */ |
163 | 163 | private function _load_dependency_map() { |
164 | - if ( ! is_readable( EE_CORE . 'EE_Dependency_Map.core.php' ) ) { |
|
164 | + if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) { |
|
165 | 165 | EE_Error::add_error( |
166 | - __( 'The EE_Dependency_Map core class could not be loaded.', 'event_espresso' ), |
|
166 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
167 | 167 | __FILE__, __FUNCTION__, __LINE__ |
168 | 168 | ); |
169 | - wp_die( EE_Error::get_notices() ); |
|
169 | + wp_die(EE_Error::get_notices()); |
|
170 | 170 | } |
171 | - require_once( EE_CORE . 'EE_Dependency_Map.core.php' ); |
|
172 | - return EE_Dependency_Map::instance( $this->request, $this->response ); |
|
171 | + require_once(EE_CORE.'EE_Dependency_Map.core.php'); |
|
172 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * @return EE_Registry |
182 | 182 | */ |
183 | 183 | private function _load_registry() { |
184 | - if ( ! is_readable( EE_CORE . 'EE_Registry.core.php' )) { |
|
184 | + if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
185 | 185 | EE_Error::add_error( |
186 | - __( 'The EE_Registry core class could not be loaded.', 'event_espresso' ), |
|
186 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
187 | 187 | __FILE__, __FUNCTION__, __LINE__ |
188 | 188 | ); |
189 | - wp_die( EE_Error::get_notices() ); |
|
189 | + wp_die(EE_Error::get_notices()); |
|
190 | 190 | } |
191 | - require_once( EE_CORE . 'EE_Registry.core.php' ); |
|
192 | - return EE_Registry::instance( $this->dependency_map ); |
|
191 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
192 | + return EE_Registry::instance($this->dependency_map); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | * @return void |
201 | 201 | */ |
202 | 202 | private function _load_class_tools() { |
203 | - if ( ! is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) { |
|
203 | + if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
204 | 204 | EE_Error::add_error( |
205 | - __( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ), |
|
205 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
206 | 206 | __FILE__, __FUNCTION__, __LINE__ |
207 | 207 | ); |
208 | 208 | } |
209 | - require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
209 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | * @param \EE_Request $request |
221 | 221 | * @param \EE_Response $response |
222 | 222 | */ |
223 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
223 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
224 | 224 | //\EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
225 | 225 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
226 | 226 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
227 | 227 | //die(); |
228 | - if ( $response->plugin_deactivated() ) { |
|
229 | - espresso_deactivate_plugin( EE_PLUGIN_BASENAME ); |
|
228 | + if ($response->plugin_deactivated()) { |
|
229 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\services\commands; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | abstract class CommandHandler implements CommandHandlerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
23 | - * @return mixed |
|
24 | - */ |
|
25 | - abstract public function handle(CommandInterface $command); |
|
21 | + /** |
|
22 | + * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
23 | + * @return mixed |
|
24 | + */ |
|
25 | + abstract public function handle(CommandInterface $command); |
|
26 | 26 | |
27 | 27 | } |
28 | 28 | // End of file CommandHandler.php |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -23,35 +23,35 @@ discard block |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @access public |
|
28 | - * @param mixed $command_bus_middleware_object |
|
29 | - * @param string $message |
|
30 | - * @param int $code |
|
31 | - * @param \Exception $previous |
|
32 | - */ |
|
33 | - public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null) |
|
34 | - { |
|
35 | - $command_bus_middleware = is_object($command_bus_middleware_object) |
|
36 | - ? get_class($command_bus_middleware_object) |
|
37 | - : gettype($command_bus_middleware_object); |
|
38 | - |
|
39 | - if (empty($message)) { |
|
40 | - $message = sprintf( |
|
41 | - __('The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
42 | - 'event_espresso'), |
|
43 | - $command_bus_middleware |
|
44 | - ); |
|
45 | - } |
|
46 | - parent::__construct( |
|
47 | - '$command_bus_middleware', |
|
48 | - $command_bus_middleware, |
|
49 | - 'CommandBusMiddlewareInterface', |
|
50 | - $message, |
|
51 | - $code, |
|
52 | - $previous |
|
53 | - ); |
|
54 | - } |
|
26 | + /** |
|
27 | + * @access public |
|
28 | + * @param mixed $command_bus_middleware_object |
|
29 | + * @param string $message |
|
30 | + * @param int $code |
|
31 | + * @param \Exception $previous |
|
32 | + */ |
|
33 | + public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null) |
|
34 | + { |
|
35 | + $command_bus_middleware = is_object($command_bus_middleware_object) |
|
36 | + ? get_class($command_bus_middleware_object) |
|
37 | + : gettype($command_bus_middleware_object); |
|
38 | + |
|
39 | + if (empty($message)) { |
|
40 | + $message = sprintf( |
|
41 | + __('The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
42 | + 'event_espresso'), |
|
43 | + $command_bus_middleware |
|
44 | + ); |
|
45 | + } |
|
46 | + parent::__construct( |
|
47 | + '$command_bus_middleware', |
|
48 | + $command_bus_middleware, |
|
49 | + 'CommandBusMiddlewareInterface', |
|
50 | + $message, |
|
51 | + $code, |
|
52 | + $previous |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | 57 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\commands\CommandRequiresCapCheckInterface; |
7 | 7 | |
8 | 8 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
9 | - exit('No direct script access allowed'); |
|
9 | + exit('No direct script access allowed'); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | |
@@ -26,39 +26,39 @@ discard block |
||
26 | 26 | class CapChecker implements CommandBusMiddlewareInterface |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @type CapabilitiesChecker $capabilities_checker |
|
31 | - */ |
|
32 | - private $capabilities_checker; |
|
29 | + /** |
|
30 | + * @type CapabilitiesChecker $capabilities_checker |
|
31 | + */ |
|
32 | + private $capabilities_checker; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * CapChecker constructor |
|
38 | - * |
|
39 | - * @param CapabilitiesChecker $capabilities_checker |
|
40 | - */ |
|
41 | - public function __construct(CapabilitiesChecker $capabilities_checker) |
|
42 | - { |
|
43 | - $this->capabilities_checker = $capabilities_checker; |
|
44 | - } |
|
36 | + /** |
|
37 | + * CapChecker constructor |
|
38 | + * |
|
39 | + * @param CapabilitiesChecker $capabilities_checker |
|
40 | + */ |
|
41 | + public function __construct(CapabilitiesChecker $capabilities_checker) |
|
42 | + { |
|
43 | + $this->capabilities_checker = $capabilities_checker; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param CommandInterface $command |
|
50 | - * @param \Closure $next |
|
51 | - * @return mixed |
|
52 | - */ |
|
53 | - public function handle(CommandInterface $command, \Closure $next) |
|
54 | - { |
|
55 | - if ( $command instanceof CommandRequiresCapCheckInterface) { |
|
56 | - $this->capabilities_checker->processCapCheck( |
|
57 | - $command->getCapCheck() |
|
58 | - ); |
|
59 | - } |
|
60 | - return $next($command); |
|
61 | - } |
|
48 | + /** |
|
49 | + * @param CommandInterface $command |
|
50 | + * @param \Closure $next |
|
51 | + * @return mixed |
|
52 | + */ |
|
53 | + public function handle(CommandInterface $command, \Closure $next) |
|
54 | + { |
|
55 | + if ( $command instanceof CommandRequiresCapCheckInterface) { |
|
56 | + $this->capabilities_checker->processCapCheck( |
|
57 | + $command->getCapCheck() |
|
58 | + ); |
|
59 | + } |
|
60 | + return $next($command); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | 64 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | */ |
53 | 53 | public function handle(CommandInterface $command, \Closure $next) |
54 | 54 | { |
55 | - if ( $command instanceof CommandRequiresCapCheckInterface) { |
|
55 | + if ($command instanceof CommandRequiresCapCheckInterface) { |
|
56 | 56 | $this->capabilities_checker->processCapCheck( |
57 | 57 | $command->getCapCheck() |
58 | 58 | ); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\services\commands\CommandInterface; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | interface CommandBusMiddlewareInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @param CommandInterface $command |
|
22 | - * @param \Closure $next |
|
23 | - * @return mixed |
|
24 | - */ |
|
25 | - public function handle(CommandInterface $command, \Closure $next); |
|
20 | + /** |
|
21 | + * @param CommandInterface $command |
|
22 | + * @param \Closure $next |
|
23 | + * @return mixed |
|
24 | + */ |
|
25 | + public function handle(CommandInterface $command, \Closure $next); |
|
26 | 26 | |
27 | 27 | } |
28 | 28 | // End of file CommandBusMiddlewareInterface.php |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\commands\middleware\InvalidCommandBusMiddlewareException; |
7 | 7 | |
8 | 8 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
9 | - exit('No direct script access allowed'); |
|
9 | + exit('No direct script access allowed'); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | |
@@ -55,73 +55,73 @@ discard block |
||
55 | 55 | class CommandBus implements CommandBusInterface |
56 | 56 | { |
57 | 57 | |
58 | - /** |
|
59 | - * @type CommandHandlerManagerInterface $command_handler_manager |
|
60 | - */ |
|
61 | - private $command_handler_manager; |
|
62 | - |
|
63 | - /** |
|
64 | - * @type CommandBusMiddlewareInterface[] $command_bus_middleware |
|
65 | - */ |
|
66 | - private $command_bus_middleware; |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * CommandBus constructor |
|
72 | - * |
|
73 | - * @param CommandHandlerManagerInterface $command_handler_manager |
|
74 | - * @param CommandBusMiddlewareInterface[] $command_bus_middleware |
|
75 | - */ |
|
76 | - public function __construct( |
|
77 | - CommandHandlerManagerInterface $command_handler_manager, |
|
78 | - $command_bus_middleware = array() |
|
79 | - ) { |
|
80 | - $this->command_handler_manager = $command_handler_manager; |
|
81 | - $this->command_bus_middleware = is_array($command_bus_middleware) |
|
82 | - ? $command_bus_middleware |
|
83 | - : array($command_bus_middleware); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return CommandHandlerManagerInterface |
|
90 | - */ |
|
91 | - public function getCommandHandlerManager() |
|
92 | - { |
|
93 | - return $this->command_handler_manager; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
100 | - * @return mixed |
|
101 | - */ |
|
102 | - public function execute($command) |
|
103 | - { |
|
104 | - if ( ! $command instanceof CommandInterface) { |
|
105 | - throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
106 | - } |
|
107 | - // expose the command to any CommandBus middleware classes |
|
108 | - // so that they can execute their logic on the command |
|
109 | - $middleware = function ($command) { |
|
110 | - // do nothing, just need an empty shell to pass along as the last middleware |
|
111 | - }; |
|
112 | - while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
|
113 | - if ( ! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
114 | - throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
|
115 | - } |
|
116 | - $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
117 | - return $command_bus_middleware->handle($command, $middleware); |
|
118 | - }; |
|
119 | - $middleware($command, $middleware); |
|
120 | - } |
|
121 | - return $this->command_handler_manager |
|
122 | - ->getCommandHandler($command) |
|
123 | - ->handle($command); |
|
124 | - } |
|
58 | + /** |
|
59 | + * @type CommandHandlerManagerInterface $command_handler_manager |
|
60 | + */ |
|
61 | + private $command_handler_manager; |
|
62 | + |
|
63 | + /** |
|
64 | + * @type CommandBusMiddlewareInterface[] $command_bus_middleware |
|
65 | + */ |
|
66 | + private $command_bus_middleware; |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * CommandBus constructor |
|
72 | + * |
|
73 | + * @param CommandHandlerManagerInterface $command_handler_manager |
|
74 | + * @param CommandBusMiddlewareInterface[] $command_bus_middleware |
|
75 | + */ |
|
76 | + public function __construct( |
|
77 | + CommandHandlerManagerInterface $command_handler_manager, |
|
78 | + $command_bus_middleware = array() |
|
79 | + ) { |
|
80 | + $this->command_handler_manager = $command_handler_manager; |
|
81 | + $this->command_bus_middleware = is_array($command_bus_middleware) |
|
82 | + ? $command_bus_middleware |
|
83 | + : array($command_bus_middleware); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return CommandHandlerManagerInterface |
|
90 | + */ |
|
91 | + public function getCommandHandlerManager() |
|
92 | + { |
|
93 | + return $this->command_handler_manager; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
100 | + * @return mixed |
|
101 | + */ |
|
102 | + public function execute($command) |
|
103 | + { |
|
104 | + if ( ! $command instanceof CommandInterface) { |
|
105 | + throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
106 | + } |
|
107 | + // expose the command to any CommandBus middleware classes |
|
108 | + // so that they can execute their logic on the command |
|
109 | + $middleware = function ($command) { |
|
110 | + // do nothing, just need an empty shell to pass along as the last middleware |
|
111 | + }; |
|
112 | + while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
|
113 | + if ( ! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
114 | + throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
|
115 | + } |
|
116 | + $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
117 | + return $command_bus_middleware->handle($command, $middleware); |
|
118 | + }; |
|
119 | + $middleware($command, $middleware); |
|
120 | + } |
|
121 | + return $this->command_handler_manager |
|
122 | + ->getCommandHandler($command) |
|
123 | + ->handle($command); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | |
127 | 127 | } |
@@ -102,18 +102,18 @@ |
||
102 | 102 | public function execute($command) |
103 | 103 | { |
104 | 104 | if ( ! $command instanceof CommandInterface) { |
105 | - throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
105 | + throw new InvalidDataTypeException(__METHOD__.'( $command )', $command, 'CommandInterface'); |
|
106 | 106 | } |
107 | 107 | // expose the command to any CommandBus middleware classes |
108 | 108 | // so that they can execute their logic on the command |
109 | - $middleware = function ($command) { |
|
109 | + $middleware = function($command) { |
|
110 | 110 | // do nothing, just need an empty shell to pass along as the last middleware |
111 | 111 | }; |
112 | 112 | while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
113 | 113 | if ( ! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
114 | 114 | throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
115 | 115 | } |
116 | - $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
116 | + $middleware = function($command) use ($command_bus_middleware, $middleware) { |
|
117 | 117 | return $command_bus_middleware->handle($command, $middleware); |
118 | 118 | }; |
119 | 119 | $middleware($command, $middleware); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\services\commands\CommandHandler; |
7 | 7 | use EventEspresso\core\services\commands\CommandInterface; |
8 | 8 | |
9 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | * @param \EventEspresso\core\services\commands\CommandInterface $command |
47 | 47 | * @return \EE_Line_Item |
48 | 48 | */ |
49 | - public function handle( CommandInterface $command ) { |
|
49 | + public function handle(CommandInterface $command) { |
|
50 | 50 | /** @var CreateTicketLineItemCommand $command */ |
51 | - if ( ! $command instanceof CreateTicketLineItemCommand ) { |
|
52 | - throw new InvalidEntityException( get_class( $command ), 'CreateTicketLineItemCommand' ); |
|
51 | + if ( ! $command instanceof CreateTicketLineItemCommand) { |
|
52 | + throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
|
53 | 53 | } |
54 | 54 | // create new line item for ticket |
55 | 55 | return $this->factory->create( |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\services\commands\Command; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -21,121 +21,121 @@ discard block |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @var \EE_Transaction $transaction |
|
26 | - */ |
|
27 | - private $transaction; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var \EE_Ticket $ticket |
|
31 | - */ |
|
32 | - private $ticket; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var \EE_Line_Item $ticket_line_item |
|
36 | - */ |
|
37 | - protected $ticket_line_item; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var int $quantity |
|
41 | - */ |
|
42 | - protected $quantity; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @param \EE_Registration $registration |
|
48 | - * @param int $quantity |
|
49 | - */ |
|
50 | - public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
51 | - { |
|
52 | - new self( |
|
53 | - $registration->transaction(), |
|
54 | - $registration->ticket(), |
|
55 | - 1, |
|
56 | - $registration->ticket_line_item() |
|
57 | - ); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @param \EE_Line_Item $ticket_line_item |
|
64 | - * @param int $quantity |
|
65 | - */ |
|
66 | - public static function fromTicketLineItem( |
|
67 | - \EE_Line_Item $ticket_line_item, |
|
68 | - $quantity = 1 |
|
69 | - ) { |
|
70 | - new self( |
|
71 | - $ticket_line_item->transaction(), |
|
72 | - $ticket_line_item->ticket(), |
|
73 | - $quantity, |
|
74 | - $ticket_line_item |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * CancelTicketLineItemCommand constructor. |
|
82 | - * |
|
83 | - * @param \EE_Transaction $transaction |
|
84 | - * @param \EE_Ticket $ticket |
|
85 | - * @param int $quantity |
|
86 | - * @param \EE_Line_Item $ticket_line_item |
|
87 | - */ |
|
88 | - public function __construct( |
|
89 | - \EE_Transaction $transaction, |
|
90 | - \EE_Ticket $ticket, |
|
91 | - $quantity = 1, |
|
92 | - \EE_Line_Item $ticket_line_item = null |
|
93 | - ) { |
|
94 | - $this->transaction = $transaction; |
|
95 | - $this->ticket = $ticket; |
|
96 | - $this->quantity = min(1, absint($quantity)); |
|
97 | - $this->ticket_line_item = $ticket_line_item; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return \EE_Transaction |
|
104 | - */ |
|
105 | - public function transaction() |
|
106 | - { |
|
107 | - return $this->transaction; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return \EE_Ticket |
|
114 | - */ |
|
115 | - public function ticket() |
|
116 | - { |
|
117 | - return $this->ticket; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return \EE_Line_Item |
|
124 | - */ |
|
125 | - public function ticketLineItem() |
|
126 | - { |
|
127 | - return $this->ticket_line_item; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @return int |
|
134 | - */ |
|
135 | - public function quantity() |
|
136 | - { |
|
137 | - return $this->quantity; |
|
138 | - } |
|
24 | + /** |
|
25 | + * @var \EE_Transaction $transaction |
|
26 | + */ |
|
27 | + private $transaction; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var \EE_Ticket $ticket |
|
31 | + */ |
|
32 | + private $ticket; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var \EE_Line_Item $ticket_line_item |
|
36 | + */ |
|
37 | + protected $ticket_line_item; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var int $quantity |
|
41 | + */ |
|
42 | + protected $quantity; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @param \EE_Registration $registration |
|
48 | + * @param int $quantity |
|
49 | + */ |
|
50 | + public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
51 | + { |
|
52 | + new self( |
|
53 | + $registration->transaction(), |
|
54 | + $registration->ticket(), |
|
55 | + 1, |
|
56 | + $registration->ticket_line_item() |
|
57 | + ); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @param \EE_Line_Item $ticket_line_item |
|
64 | + * @param int $quantity |
|
65 | + */ |
|
66 | + public static function fromTicketLineItem( |
|
67 | + \EE_Line_Item $ticket_line_item, |
|
68 | + $quantity = 1 |
|
69 | + ) { |
|
70 | + new self( |
|
71 | + $ticket_line_item->transaction(), |
|
72 | + $ticket_line_item->ticket(), |
|
73 | + $quantity, |
|
74 | + $ticket_line_item |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * CancelTicketLineItemCommand constructor. |
|
82 | + * |
|
83 | + * @param \EE_Transaction $transaction |
|
84 | + * @param \EE_Ticket $ticket |
|
85 | + * @param int $quantity |
|
86 | + * @param \EE_Line_Item $ticket_line_item |
|
87 | + */ |
|
88 | + public function __construct( |
|
89 | + \EE_Transaction $transaction, |
|
90 | + \EE_Ticket $ticket, |
|
91 | + $quantity = 1, |
|
92 | + \EE_Line_Item $ticket_line_item = null |
|
93 | + ) { |
|
94 | + $this->transaction = $transaction; |
|
95 | + $this->ticket = $ticket; |
|
96 | + $this->quantity = min(1, absint($quantity)); |
|
97 | + $this->ticket_line_item = $ticket_line_item; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return \EE_Transaction |
|
104 | + */ |
|
105 | + public function transaction() |
|
106 | + { |
|
107 | + return $this->transaction; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return \EE_Ticket |
|
114 | + */ |
|
115 | + public function ticket() |
|
116 | + { |
|
117 | + return $this->ticket; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return \EE_Line_Item |
|
124 | + */ |
|
125 | + public function ticketLineItem() |
|
126 | + { |
|
127 | + return $this->ticket_line_item; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @return int |
|
134 | + */ |
|
135 | + public function quantity() |
|
136 | + { |
|
137 | + return $this->quantity; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | |
141 | 141 | } |