@@ -19,38 +19,38 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
24 | - */ |
|
25 | - private $cancel_ticket_line_item_service; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * Command constructor |
|
30 | - * |
|
31 | - * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
32 | - */ |
|
33 | - public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
34 | - { |
|
35 | - $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
41 | - * @return boolean |
|
42 | - */ |
|
43 | - public function handle(CommandInterface $command) |
|
44 | - { |
|
45 | - /** @var CancelRegistrationAndTicketLineItemCommand $command */ |
|
46 | - if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
47 | - throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand'); |
|
48 | - } |
|
49 | - $registration = $command->registration(); |
|
50 | - $this->cancel_ticket_line_item_service->forRegistration($registration); |
|
51 | - // cancel original registration |
|
52 | - $registration->set_status(\EEM_Registration::status_id_cancelled); |
|
53 | - $registration->save(); |
|
54 | - return true; |
|
55 | - } |
|
22 | + /** |
|
23 | + * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
24 | + */ |
|
25 | + private $cancel_ticket_line_item_service; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * Command constructor |
|
30 | + * |
|
31 | + * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
32 | + */ |
|
33 | + public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
34 | + { |
|
35 | + $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
41 | + * @return boolean |
|
42 | + */ |
|
43 | + public function handle(CommandInterface $command) |
|
44 | + { |
|
45 | + /** @var CancelRegistrationAndTicketLineItemCommand $command */ |
|
46 | + if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
47 | + throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand'); |
|
48 | + } |
|
49 | + $registration = $command->registration(); |
|
50 | + $this->cancel_ticket_line_item_service->forRegistration($registration); |
|
51 | + // cancel original registration |
|
52 | + $registration->set_status(\EEM_Registration::status_id_cancelled); |
|
53 | + $registration->save(); |
|
54 | + return true; |
|
55 | + } |
|
56 | 56 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | public function handle(CommandInterface $command) |
61 | 61 | { |
62 | 62 | /** @var CancelRegistrationAndTicketLineItemCommand $command */ |
63 | - if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
63 | + if ( ! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
64 | 64 | throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand'); |
65 | 65 | } |
66 | 66 | $registration = $command->registration(); |
@@ -34,73 +34,73 @@ |
||
34 | 34 | class CommandBus implements CommandBusInterface |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * @type CommandHandlerManagerInterface $command_handler_manager |
|
39 | - */ |
|
40 | - private $command_handler_manager; |
|
37 | + /** |
|
38 | + * @type CommandHandlerManagerInterface $command_handler_manager |
|
39 | + */ |
|
40 | + private $command_handler_manager; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @type CommandBusMiddlewareInterface[] $command_bus_middleware |
|
44 | - */ |
|
45 | - private $command_bus_middleware; |
|
42 | + /** |
|
43 | + * @type CommandBusMiddlewareInterface[] $command_bus_middleware |
|
44 | + */ |
|
45 | + private $command_bus_middleware; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * CommandBus constructor |
|
50 | - * |
|
51 | - * @param CommandHandlerManagerInterface $command_handler_manager |
|
52 | - * @param CommandBusMiddlewareInterface[] $command_bus_middleware |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - CommandHandlerManagerInterface $command_handler_manager, |
|
56 | - array $command_bus_middleware = array() |
|
57 | - ) { |
|
58 | - $this->command_handler_manager = $command_handler_manager; |
|
59 | - $this->command_bus_middleware = is_array($command_bus_middleware) |
|
60 | - ? $command_bus_middleware |
|
61 | - : array($command_bus_middleware); |
|
62 | - } |
|
48 | + /** |
|
49 | + * CommandBus constructor |
|
50 | + * |
|
51 | + * @param CommandHandlerManagerInterface $command_handler_manager |
|
52 | + * @param CommandBusMiddlewareInterface[] $command_bus_middleware |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + CommandHandlerManagerInterface $command_handler_manager, |
|
56 | + array $command_bus_middleware = array() |
|
57 | + ) { |
|
58 | + $this->command_handler_manager = $command_handler_manager; |
|
59 | + $this->command_bus_middleware = is_array($command_bus_middleware) |
|
60 | + ? $command_bus_middleware |
|
61 | + : array($command_bus_middleware); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @return CommandHandlerManagerInterface |
|
67 | - */ |
|
68 | - public function getCommandHandlerManager() |
|
69 | - { |
|
70 | - return $this->command_handler_manager; |
|
71 | - } |
|
65 | + /** |
|
66 | + * @return CommandHandlerManagerInterface |
|
67 | + */ |
|
68 | + public function getCommandHandlerManager() |
|
69 | + { |
|
70 | + return $this->command_handler_manager; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * @param CommandInterface $command |
|
76 | - * @return mixed |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws InvalidCommandBusMiddlewareException |
|
79 | - */ |
|
80 | - public function execute($command) |
|
81 | - { |
|
82 | - if (! $command instanceof CommandInterface) { |
|
83 | - throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
84 | - } |
|
85 | - // we're going to add the Command Handler as a callable |
|
86 | - // that will get run at the end of our middleware stack |
|
87 | - // can't pass $this to a Closure, so use a named variable |
|
88 | - $command_bus = $this; |
|
89 | - $middleware = function ($command) use ($command_bus) { |
|
90 | - return $command_bus->getCommandHandlerManager() |
|
91 | - ->getCommandHandler($command, $command_bus) |
|
92 | - ->handle($command); |
|
93 | - }; |
|
94 | - // now build the rest of the middleware stack |
|
95 | - while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
|
96 | - if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
97 | - throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
|
98 | - } |
|
99 | - $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
100 | - return $command_bus_middleware->handle($command, $middleware); |
|
101 | - }; |
|
102 | - } |
|
103 | - // and finally, pass the command into the stack and return the results |
|
104 | - return $middleware($command); |
|
105 | - } |
|
74 | + /** |
|
75 | + * @param CommandInterface $command |
|
76 | + * @return mixed |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws InvalidCommandBusMiddlewareException |
|
79 | + */ |
|
80 | + public function execute($command) |
|
81 | + { |
|
82 | + if (! $command instanceof CommandInterface) { |
|
83 | + throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
84 | + } |
|
85 | + // we're going to add the Command Handler as a callable |
|
86 | + // that will get run at the end of our middleware stack |
|
87 | + // can't pass $this to a Closure, so use a named variable |
|
88 | + $command_bus = $this; |
|
89 | + $middleware = function ($command) use ($command_bus) { |
|
90 | + return $command_bus->getCommandHandlerManager() |
|
91 | + ->getCommandHandler($command, $command_bus) |
|
92 | + ->handle($command); |
|
93 | + }; |
|
94 | + // now build the rest of the middleware stack |
|
95 | + while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
|
96 | + if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
97 | + throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
|
98 | + } |
|
99 | + $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
100 | + return $command_bus_middleware->handle($command, $middleware); |
|
101 | + }; |
|
102 | + } |
|
103 | + // and finally, pass the command into the stack and return the results |
|
104 | + return $middleware($command); |
|
105 | + } |
|
106 | 106 | } |
@@ -79,24 +79,24 @@ |
||
79 | 79 | */ |
80 | 80 | public function execute($command) |
81 | 81 | { |
82 | - if (! $command instanceof CommandInterface) { |
|
83 | - throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface'); |
|
82 | + if ( ! $command instanceof CommandInterface) { |
|
83 | + throw new InvalidDataTypeException(__METHOD__.'( $command )', $command, 'CommandInterface'); |
|
84 | 84 | } |
85 | 85 | // we're going to add the Command Handler as a callable |
86 | 86 | // that will get run at the end of our middleware stack |
87 | 87 | // can't pass $this to a Closure, so use a named variable |
88 | 88 | $command_bus = $this; |
89 | - $middleware = function ($command) use ($command_bus) { |
|
89 | + $middleware = function($command) use ($command_bus) { |
|
90 | 90 | return $command_bus->getCommandHandlerManager() |
91 | 91 | ->getCommandHandler($command, $command_bus) |
92 | 92 | ->handle($command); |
93 | 93 | }; |
94 | 94 | // now build the rest of the middleware stack |
95 | 95 | while ($command_bus_middleware = array_pop($this->command_bus_middleware)) { |
96 | - if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
96 | + if ( ! $command_bus_middleware instanceof CommandBusMiddlewareInterface) { |
|
97 | 97 | throw new InvalidCommandBusMiddlewareException($command_bus_middleware); |
98 | 98 | } |
99 | - $middleware = function ($command) use ($command_bus_middleware, $middleware) { |
|
99 | + $middleware = function($command) use ($command_bus_middleware, $middleware) { |
|
100 | 100 | return $command_bus_middleware->handle($command, $middleware); |
101 | 101 | }; |
102 | 102 | } |
@@ -15,22 +15,22 @@ |
||
15 | 15 | class AddActionHook implements CommandBusMiddlewareInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param CommandInterface $command |
|
20 | - * @param Closure $next |
|
21 | - * @return mixed |
|
22 | - */ |
|
23 | - public function handle(CommandInterface $command, Closure $next) |
|
24 | - { |
|
25 | - do_action( |
|
26 | - 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before', |
|
27 | - $command |
|
28 | - ); |
|
29 | - $results = $next($command); |
|
30 | - do_action( |
|
31 | - 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after', |
|
32 | - $command |
|
33 | - ); |
|
34 | - return $results; |
|
35 | - } |
|
18 | + /** |
|
19 | + * @param CommandInterface $command |
|
20 | + * @param Closure $next |
|
21 | + * @return mixed |
|
22 | + */ |
|
23 | + public function handle(CommandInterface $command, Closure $next) |
|
24 | + { |
|
25 | + do_action( |
|
26 | + 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before', |
|
27 | + $command |
|
28 | + ); |
|
29 | + $results = $next($command); |
|
30 | + do_action( |
|
31 | + 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after', |
|
32 | + $command |
|
33 | + ); |
|
34 | + return $results; |
|
35 | + } |
|
36 | 36 | } |
@@ -16,35 +16,35 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @access public |
|
21 | - * @param mixed $command_bus_middleware_object |
|
22 | - * @param string $message |
|
23 | - * @param int $code |
|
24 | - * @param \Exception $previous |
|
25 | - */ |
|
26 | - public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null) |
|
27 | - { |
|
28 | - $command_bus_middleware = is_object($command_bus_middleware_object) |
|
29 | - ? get_class($command_bus_middleware_object) |
|
30 | - : gettype($command_bus_middleware_object); |
|
19 | + /** |
|
20 | + * @access public |
|
21 | + * @param mixed $command_bus_middleware_object |
|
22 | + * @param string $message |
|
23 | + * @param int $code |
|
24 | + * @param \Exception $previous |
|
25 | + */ |
|
26 | + public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null) |
|
27 | + { |
|
28 | + $command_bus_middleware = is_object($command_bus_middleware_object) |
|
29 | + ? get_class($command_bus_middleware_object) |
|
30 | + : gettype($command_bus_middleware_object); |
|
31 | 31 | |
32 | - if (empty($message)) { |
|
33 | - $message = sprintf( |
|
34 | - __( |
|
35 | - 'The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - $command_bus_middleware |
|
39 | - ); |
|
40 | - } |
|
41 | - parent::__construct( |
|
42 | - '$command_bus_middleware', |
|
43 | - $command_bus_middleware, |
|
44 | - 'CommandBusMiddlewareInterface', |
|
45 | - $message, |
|
46 | - $code, |
|
47 | - $previous |
|
48 | - ); |
|
49 | - } |
|
32 | + if (empty($message)) { |
|
33 | + $message = sprintf( |
|
34 | + __( |
|
35 | + 'The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + $command_bus_middleware |
|
39 | + ); |
|
40 | + } |
|
41 | + parent::__construct( |
|
42 | + '$command_bus_middleware', |
|
43 | + $command_bus_middleware, |
|
44 | + 'CommandBusMiddlewareInterface', |
|
45 | + $message, |
|
46 | + $code, |
|
47 | + $previous |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | } |
@@ -24,37 +24,37 @@ |
||
24 | 24 | class CapChecker implements CommandBusMiddlewareInterface |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @type CapabilitiesCheckerInterface $capabilities_checker |
|
29 | - */ |
|
30 | - private $capabilities_checker; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * CapChecker constructor |
|
35 | - * |
|
36 | - * @param CapabilitiesCheckerInterface $capabilities_checker |
|
37 | - */ |
|
38 | - public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
39 | - { |
|
40 | - $this->capabilities_checker = $capabilities_checker; |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @param CommandInterface $command |
|
46 | - * @param Closure $next |
|
47 | - * @return mixed |
|
48 | - * @throws InvalidClassException |
|
49 | - * @throws InsufficientPermissionsException |
|
50 | - */ |
|
51 | - public function handle(CommandInterface $command, Closure $next) |
|
52 | - { |
|
53 | - if ($command instanceof CommandRequiresCapCheckInterface) { |
|
54 | - $this->capabilities_checker->processCapCheck( |
|
55 | - $command->getCapCheck() |
|
56 | - ); |
|
57 | - } |
|
58 | - return $next($command); |
|
59 | - } |
|
27 | + /** |
|
28 | + * @type CapabilitiesCheckerInterface $capabilities_checker |
|
29 | + */ |
|
30 | + private $capabilities_checker; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * CapChecker constructor |
|
35 | + * |
|
36 | + * @param CapabilitiesCheckerInterface $capabilities_checker |
|
37 | + */ |
|
38 | + public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
39 | + { |
|
40 | + $this->capabilities_checker = $capabilities_checker; |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @param CommandInterface $command |
|
46 | + * @param Closure $next |
|
47 | + * @return mixed |
|
48 | + * @throws InvalidClassException |
|
49 | + * @throws InsufficientPermissionsException |
|
50 | + */ |
|
51 | + public function handle(CommandInterface $command, Closure $next) |
|
52 | + { |
|
53 | + if ($command instanceof CommandRequiresCapCheckInterface) { |
|
54 | + $this->capabilities_checker->processCapCheck( |
|
55 | + $command->getCapCheck() |
|
56 | + ); |
|
57 | + } |
|
58 | + return $next($command); |
|
59 | + } |
|
60 | 60 | } |
@@ -19,41 +19,41 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @var CreateTicketLineItemService $factory |
|
24 | - */ |
|
25 | - private $factory; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * Command constructor |
|
30 | - * |
|
31 | - * @param CreateTicketLineItemService $factory |
|
32 | - */ |
|
33 | - public function __construct(CreateTicketLineItemService $factory) |
|
34 | - { |
|
35 | - $this->factory = $factory; |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
41 | - * @return \EE_Line_Item |
|
42 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
43 | - * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
44 | - * @throws \EE_Error |
|
45 | - */ |
|
46 | - public function handle(CommandInterface $command) |
|
47 | - { |
|
48 | - /** @var CreateTicketLineItemCommand $command */ |
|
49 | - if (! $command instanceof CreateTicketLineItemCommand) { |
|
50 | - throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
|
51 | - } |
|
52 | - // create new line item for ticket |
|
53 | - return $this->factory->create( |
|
54 | - $command->transaction(), |
|
55 | - $command->ticket(), |
|
56 | - $command->quantity() |
|
57 | - ); |
|
58 | - } |
|
22 | + /** |
|
23 | + * @var CreateTicketLineItemService $factory |
|
24 | + */ |
|
25 | + private $factory; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * Command constructor |
|
30 | + * |
|
31 | + * @param CreateTicketLineItemService $factory |
|
32 | + */ |
|
33 | + public function __construct(CreateTicketLineItemService $factory) |
|
34 | + { |
|
35 | + $this->factory = $factory; |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
41 | + * @return \EE_Line_Item |
|
42 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
43 | + * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
44 | + * @throws \EE_Error |
|
45 | + */ |
|
46 | + public function handle(CommandInterface $command) |
|
47 | + { |
|
48 | + /** @var CreateTicketLineItemCommand $command */ |
|
49 | + if (! $command instanceof CreateTicketLineItemCommand) { |
|
50 | + throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
|
51 | + } |
|
52 | + // create new line item for ticket |
|
53 | + return $this->factory->create( |
|
54 | + $command->transaction(), |
|
55 | + $command->ticket(), |
|
56 | + $command->quantity() |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | public function handle(CommandInterface $command) |
53 | 53 | { |
54 | 54 | /** @var CreateTicketLineItemCommand $command */ |
55 | - if (! $command instanceof CreateTicketLineItemCommand) { |
|
55 | + if ( ! $command instanceof CreateTicketLineItemCommand) { |
|
56 | 56 | throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
57 | 57 | } |
58 | 58 | // create new line item for ticket |
@@ -16,112 +16,112 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Transaction $transaction |
|
21 | - */ |
|
22 | - private $transaction; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket $ticket |
|
26 | - */ |
|
27 | - private $ticket; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var \EE_Line_Item $ticket_line_item |
|
31 | - */ |
|
32 | - protected $ticket_line_item; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var int $quantity |
|
36 | - */ |
|
37 | - protected $quantity; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param \EE_Registration $registration |
|
42 | - * @param int $quantity |
|
43 | - */ |
|
44 | - public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
45 | - { |
|
46 | - new self( |
|
47 | - $registration->transaction(), |
|
48 | - $registration->ticket(), |
|
49 | - 1, |
|
50 | - $registration->ticket_line_item() |
|
51 | - ); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param \EE_Line_Item $ticket_line_item |
|
57 | - * @param int $quantity |
|
58 | - */ |
|
59 | - public static function fromTicketLineItem( |
|
60 | - \EE_Line_Item $ticket_line_item, |
|
61 | - $quantity = 1 |
|
62 | - ) { |
|
63 | - new self( |
|
64 | - $ticket_line_item->transaction(), |
|
65 | - $ticket_line_item->ticket(), |
|
66 | - $quantity, |
|
67 | - $ticket_line_item |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * CancelTicketLineItemCommand constructor. |
|
74 | - * |
|
75 | - * @param \EE_Transaction $transaction |
|
76 | - * @param \EE_Ticket $ticket |
|
77 | - * @param int $quantity |
|
78 | - * @param \EE_Line_Item $ticket_line_item |
|
79 | - */ |
|
80 | - public function __construct( |
|
81 | - \EE_Transaction $transaction, |
|
82 | - \EE_Ticket $ticket, |
|
83 | - $quantity = 1, |
|
84 | - \EE_Line_Item $ticket_line_item = null |
|
85 | - ) { |
|
86 | - $this->transaction = $transaction; |
|
87 | - $this->ticket = $ticket; |
|
88 | - $this->quantity = min(1, absint($quantity)); |
|
89 | - $this->ticket_line_item = $ticket_line_item; |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @return \EE_Transaction |
|
95 | - */ |
|
96 | - public function transaction() |
|
97 | - { |
|
98 | - return $this->transaction; |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return \EE_Ticket |
|
104 | - */ |
|
105 | - public function ticket() |
|
106 | - { |
|
107 | - return $this->ticket; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @return \EE_Line_Item |
|
113 | - */ |
|
114 | - public function ticketLineItem() |
|
115 | - { |
|
116 | - return $this->ticket_line_item; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * @return int |
|
122 | - */ |
|
123 | - public function quantity() |
|
124 | - { |
|
125 | - return $this->quantity; |
|
126 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Transaction $transaction |
|
21 | + */ |
|
22 | + private $transaction; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket $ticket |
|
26 | + */ |
|
27 | + private $ticket; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var \EE_Line_Item $ticket_line_item |
|
31 | + */ |
|
32 | + protected $ticket_line_item; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var int $quantity |
|
36 | + */ |
|
37 | + protected $quantity; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param \EE_Registration $registration |
|
42 | + * @param int $quantity |
|
43 | + */ |
|
44 | + public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
45 | + { |
|
46 | + new self( |
|
47 | + $registration->transaction(), |
|
48 | + $registration->ticket(), |
|
49 | + 1, |
|
50 | + $registration->ticket_line_item() |
|
51 | + ); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param \EE_Line_Item $ticket_line_item |
|
57 | + * @param int $quantity |
|
58 | + */ |
|
59 | + public static function fromTicketLineItem( |
|
60 | + \EE_Line_Item $ticket_line_item, |
|
61 | + $quantity = 1 |
|
62 | + ) { |
|
63 | + new self( |
|
64 | + $ticket_line_item->transaction(), |
|
65 | + $ticket_line_item->ticket(), |
|
66 | + $quantity, |
|
67 | + $ticket_line_item |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * CancelTicketLineItemCommand constructor. |
|
74 | + * |
|
75 | + * @param \EE_Transaction $transaction |
|
76 | + * @param \EE_Ticket $ticket |
|
77 | + * @param int $quantity |
|
78 | + * @param \EE_Line_Item $ticket_line_item |
|
79 | + */ |
|
80 | + public function __construct( |
|
81 | + \EE_Transaction $transaction, |
|
82 | + \EE_Ticket $ticket, |
|
83 | + $quantity = 1, |
|
84 | + \EE_Line_Item $ticket_line_item = null |
|
85 | + ) { |
|
86 | + $this->transaction = $transaction; |
|
87 | + $this->ticket = $ticket; |
|
88 | + $this->quantity = min(1, absint($quantity)); |
|
89 | + $this->ticket_line_item = $ticket_line_item; |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @return \EE_Transaction |
|
95 | + */ |
|
96 | + public function transaction() |
|
97 | + { |
|
98 | + return $this->transaction; |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return \EE_Ticket |
|
104 | + */ |
|
105 | + public function ticket() |
|
106 | + { |
|
107 | + return $this->ticket; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @return \EE_Line_Item |
|
113 | + */ |
|
114 | + public function ticketLineItem() |
|
115 | + { |
|
116 | + return $this->ticket_line_item; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * @return int |
|
122 | + */ |
|
123 | + public function quantity() |
|
124 | + { |
|
125 | + return $this->quantity; |
|
126 | + } |
|
127 | 127 | } |
@@ -22,38 +22,38 @@ |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
27 | - */ |
|
28 | - private $cancel_ticket_line_item_service; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * Command constructor |
|
33 | - * |
|
34 | - * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
35 | - */ |
|
36 | - public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
37 | - { |
|
38 | - $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
44 | - * @return mixed |
|
45 | - */ |
|
46 | - public function handle(CommandInterface $command) |
|
47 | - { |
|
48 | - /** @var CancelTicketLineItemCommand $command */ |
|
49 | - if (! $command instanceof CancelTicketLineItemCommand) { |
|
50 | - throw new InvalidEntityException(get_class($command), 'CancelTicketLineItemCommand'); |
|
51 | - } |
|
52 | - return $this->cancel_ticket_line_item_service->cancel( |
|
53 | - $command->transaction(), |
|
54 | - $command->ticket(), |
|
55 | - $command->quantity(), |
|
56 | - $command->ticketLineItem() |
|
57 | - ); |
|
58 | - } |
|
25 | + /** |
|
26 | + * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
27 | + */ |
|
28 | + private $cancel_ticket_line_item_service; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * Command constructor |
|
33 | + * |
|
34 | + * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
35 | + */ |
|
36 | + public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
37 | + { |
|
38 | + $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @param \EventEspresso\core\services\commands\CommandInterface $command |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | + public function handle(CommandInterface $command) |
|
47 | + { |
|
48 | + /** @var CancelTicketLineItemCommand $command */ |
|
49 | + if (! $command instanceof CancelTicketLineItemCommand) { |
|
50 | + throw new InvalidEntityException(get_class($command), 'CancelTicketLineItemCommand'); |
|
51 | + } |
|
52 | + return $this->cancel_ticket_line_item_service->cancel( |
|
53 | + $command->transaction(), |
|
54 | + $command->ticket(), |
|
55 | + $command->quantity(), |
|
56 | + $command->ticketLineItem() |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | public function handle(CommandInterface $command) |
52 | 52 | { |
53 | 53 | /** @var CancelTicketLineItemCommand $command */ |
54 | - if (! $command instanceof CancelTicketLineItemCommand) { |
|
54 | + if ( ! $command instanceof CancelTicketLineItemCommand) { |
|
55 | 55 | throw new InvalidEntityException(get_class($command), 'CancelTicketLineItemCommand'); |
56 | 56 | } |
57 | 57 | return $this->cancel_ticket_line_item_service->cancel( |
@@ -16,77 +16,77 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Transaction $transaction |
|
21 | - */ |
|
22 | - private $transaction; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket $ticket |
|
26 | - */ |
|
27 | - private $ticket; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var int $quantity |
|
31 | - */ |
|
32 | - private $quantity = 1; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var \EE_Line_Item $ticket_line_item |
|
36 | - */ |
|
37 | - protected $ticket_line_item; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * CreateTicketLineItemCommand constructor. |
|
42 | - * |
|
43 | - * @param \EE_Transaction $transaction |
|
44 | - * @param \EE_Ticket $ticket |
|
45 | - * @param int $quantity |
|
46 | - */ |
|
47 | - public function __construct( |
|
48 | - \EE_Transaction $transaction, |
|
49 | - \EE_Ticket $ticket, |
|
50 | - $quantity = 1 |
|
51 | - ) { |
|
52 | - $this->transaction = $transaction; |
|
53 | - $this->ticket = $ticket; |
|
54 | - $this->quantity = $quantity; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @return \EE_Transaction |
|
60 | - */ |
|
61 | - public function transaction() |
|
62 | - { |
|
63 | - return $this->transaction; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return \EE_Ticket |
|
69 | - */ |
|
70 | - public function ticket() |
|
71 | - { |
|
72 | - return $this->ticket; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @return int |
|
78 | - */ |
|
79 | - public function quantity() |
|
80 | - { |
|
81 | - return $this->quantity; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @return \EE_Line_Item |
|
87 | - */ |
|
88 | - public function ticketLineItem() |
|
89 | - { |
|
90 | - return $this->ticket_line_item; |
|
91 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Transaction $transaction |
|
21 | + */ |
|
22 | + private $transaction; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket $ticket |
|
26 | + */ |
|
27 | + private $ticket; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var int $quantity |
|
31 | + */ |
|
32 | + private $quantity = 1; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var \EE_Line_Item $ticket_line_item |
|
36 | + */ |
|
37 | + protected $ticket_line_item; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * CreateTicketLineItemCommand constructor. |
|
42 | + * |
|
43 | + * @param \EE_Transaction $transaction |
|
44 | + * @param \EE_Ticket $ticket |
|
45 | + * @param int $quantity |
|
46 | + */ |
|
47 | + public function __construct( |
|
48 | + \EE_Transaction $transaction, |
|
49 | + \EE_Ticket $ticket, |
|
50 | + $quantity = 1 |
|
51 | + ) { |
|
52 | + $this->transaction = $transaction; |
|
53 | + $this->ticket = $ticket; |
|
54 | + $this->quantity = $quantity; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @return \EE_Transaction |
|
60 | + */ |
|
61 | + public function transaction() |
|
62 | + { |
|
63 | + return $this->transaction; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return \EE_Ticket |
|
69 | + */ |
|
70 | + public function ticket() |
|
71 | + { |
|
72 | + return $this->ticket; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @return int |
|
78 | + */ |
|
79 | + public function quantity() |
|
80 | + { |
|
81 | + return $this->quantity; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @return \EE_Line_Item |
|
87 | + */ |
|
88 | + public function ticketLineItem() |
|
89 | + { |
|
90 | + return $this->ticket_line_item; |
|
91 | + } |
|
92 | 92 | } |