Completed
Branch dependabot/composer/tijsverkoy... (491ea6)
by
unknown
32:00 queued 25:42
created
core/domain/services/commands/ticket/CreateTicketLineItemCommand.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,77 +17,77 @@
 block discarded – undo
17 17
  */
18 18
 class CreateTicketLineItemCommand extends Command
19 19
 {
20
-    /**
21
-     * @var EE_Transaction $transaction
22
-     */
23
-    private $transaction;
24
-
25
-    /**
26
-     * @var EE_Ticket $ticket
27
-     */
28
-    private $ticket;
29
-
30
-    /**
31
-     * @var int $quantity
32
-     */
33
-    private $quantity = 1;
34
-
35
-    /**
36
-     * @var EE_Line_Item $ticket_line_item
37
-     */
38
-    protected $ticket_line_item;
39
-
40
-
41
-    /**
42
-     * CreateTicketLineItemCommand constructor.
43
-     *
44
-     * @param EE_Transaction $transaction
45
-     * @param EE_Ticket      $ticket
46
-     * @param int            $quantity
47
-     */
48
-    public function __construct(
49
-        EE_Transaction $transaction,
50
-        EE_Ticket $ticket,
51
-        $quantity = 1
52
-    ) {
53
-        $this->transaction = $transaction;
54
-        $this->ticket      = $ticket;
55
-        $this->quantity    = $quantity;
56
-    }
57
-
58
-
59
-    /**
60
-     * @return EE_Transaction
61
-     */
62
-    public function transaction()
63
-    {
64
-        return $this->transaction;
65
-    }
66
-
67
-
68
-    /**
69
-     * @return EE_Ticket
70
-     */
71
-    public function ticket()
72
-    {
73
-        return $this->ticket;
74
-    }
75
-
76
-
77
-    /**
78
-     * @return int
79
-     */
80
-    public function quantity()
81
-    {
82
-        return $this->quantity;
83
-    }
84
-
85
-
86
-    /**
87
-     * @return EE_Line_Item
88
-     */
89
-    public function ticketLineItem()
90
-    {
91
-        return $this->ticket_line_item;
92
-    }
20
+	/**
21
+	 * @var EE_Transaction $transaction
22
+	 */
23
+	private $transaction;
24
+
25
+	/**
26
+	 * @var EE_Ticket $ticket
27
+	 */
28
+	private $ticket;
29
+
30
+	/**
31
+	 * @var int $quantity
32
+	 */
33
+	private $quantity = 1;
34
+
35
+	/**
36
+	 * @var EE_Line_Item $ticket_line_item
37
+	 */
38
+	protected $ticket_line_item;
39
+
40
+
41
+	/**
42
+	 * CreateTicketLineItemCommand constructor.
43
+	 *
44
+	 * @param EE_Transaction $transaction
45
+	 * @param EE_Ticket      $ticket
46
+	 * @param int            $quantity
47
+	 */
48
+	public function __construct(
49
+		EE_Transaction $transaction,
50
+		EE_Ticket $ticket,
51
+		$quantity = 1
52
+	) {
53
+		$this->transaction = $transaction;
54
+		$this->ticket      = $ticket;
55
+		$this->quantity    = $quantity;
56
+	}
57
+
58
+
59
+	/**
60
+	 * @return EE_Transaction
61
+	 */
62
+	public function transaction()
63
+	{
64
+		return $this->transaction;
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return EE_Ticket
70
+	 */
71
+	public function ticket()
72
+	{
73
+		return $this->ticket;
74
+	}
75
+
76
+
77
+	/**
78
+	 * @return int
79
+	 */
80
+	public function quantity()
81
+	{
82
+		return $this->quantity;
83
+	}
84
+
85
+
86
+	/**
87
+	 * @return EE_Line_Item
88
+	 */
89
+	public function ticketLineItem()
90
+	{
91
+		return $this->ticket_line_item;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
core/domain/services/commands/ticket/CancelTicketLineItemCommand.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -20,115 +20,115 @@
 block discarded – undo
20 20
  */
21 21
 class CancelTicketLineItemCommand extends Command
22 22
 {
23
-    /**
24
-     * @var EE_Transaction $transaction
25
-     */
26
-    private $transaction;
27
-
28
-    /**
29
-     * @var EE_Ticket $ticket
30
-     */
31
-    private $ticket;
32
-
33
-    /**
34
-     * @var EE_Line_Item $ticket_line_item
35
-     */
36
-    protected $ticket_line_item;
37
-
38
-    /**
39
-     * @var int $quantity
40
-     */
41
-    protected $quantity;
42
-
43
-
44
-    /**
45
-     * @param EE_Registration $registration
46
-     * @param int             $quantity
47
-     * @throws EE_Error
48
-     * @throws EntityNotFoundException
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
-     * @param EE_Line_Item $ticket_line_item
63
-     * @param int          $quantity
64
-     * @throws EE_Error
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
-     * CancelTicketLineItemCommand constructor.
81
-     *
82
-     * @param EE_Transaction $transaction
83
-     * @param EE_Ticket      $ticket
84
-     * @param int            $quantity
85
-     * @param EE_Line_Item   $ticket_line_item
86
-     */
87
-    public function __construct(
88
-        EE_Transaction $transaction,
89
-        EE_Ticket $ticket,
90
-        $quantity = 1,
91
-        EE_Line_Item $ticket_line_item = null
92
-    ) {
93
-        $this->transaction      = $transaction;
94
-        $this->ticket           = $ticket;
95
-        $this->quantity         = min(1, absint($quantity));
96
-        $this->ticket_line_item = $ticket_line_item;
97
-    }
98
-
99
-
100
-    /**
101
-     * @return EE_Transaction
102
-     */
103
-    public function transaction()
104
-    {
105
-        return $this->transaction;
106
-    }
107
-
108
-
109
-    /**
110
-     * @return EE_Ticket
111
-     */
112
-    public function ticket()
113
-    {
114
-        return $this->ticket;
115
-    }
116
-
117
-
118
-    /**
119
-     * @return EE_Line_Item
120
-     */
121
-    public function ticketLineItem()
122
-    {
123
-        return $this->ticket_line_item;
124
-    }
125
-
126
-
127
-    /**
128
-     * @return int
129
-     */
130
-    public function quantity()
131
-    {
132
-        return $this->quantity;
133
-    }
23
+	/**
24
+	 * @var EE_Transaction $transaction
25
+	 */
26
+	private $transaction;
27
+
28
+	/**
29
+	 * @var EE_Ticket $ticket
30
+	 */
31
+	private $ticket;
32
+
33
+	/**
34
+	 * @var EE_Line_Item $ticket_line_item
35
+	 */
36
+	protected $ticket_line_item;
37
+
38
+	/**
39
+	 * @var int $quantity
40
+	 */
41
+	protected $quantity;
42
+
43
+
44
+	/**
45
+	 * @param EE_Registration $registration
46
+	 * @param int             $quantity
47
+	 * @throws EE_Error
48
+	 * @throws EntityNotFoundException
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
+	 * @param EE_Line_Item $ticket_line_item
63
+	 * @param int          $quantity
64
+	 * @throws EE_Error
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
+	 * CancelTicketLineItemCommand constructor.
81
+	 *
82
+	 * @param EE_Transaction $transaction
83
+	 * @param EE_Ticket      $ticket
84
+	 * @param int            $quantity
85
+	 * @param EE_Line_Item   $ticket_line_item
86
+	 */
87
+	public function __construct(
88
+		EE_Transaction $transaction,
89
+		EE_Ticket $ticket,
90
+		$quantity = 1,
91
+		EE_Line_Item $ticket_line_item = null
92
+	) {
93
+		$this->transaction      = $transaction;
94
+		$this->ticket           = $ticket;
95
+		$this->quantity         = min(1, absint($quantity));
96
+		$this->ticket_line_item = $ticket_line_item;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return EE_Transaction
102
+	 */
103
+	public function transaction()
104
+	{
105
+		return $this->transaction;
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return EE_Ticket
111
+	 */
112
+	public function ticket()
113
+	{
114
+		return $this->ticket;
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return EE_Line_Item
120
+	 */
121
+	public function ticketLineItem()
122
+	{
123
+		return $this->ticket_line_item;
124
+	}
125
+
126
+
127
+	/**
128
+	 * @return int
129
+	 */
130
+	public function quantity()
131
+	{
132
+		return $this->quantity;
133
+	}
134 134
 }
Please login to merge, or discard this patch.
services/commands/registration/CopyRegistrationDetailsCommandHandler.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -22,38 +22,38 @@
 block discarded – undo
22 22
  */
23 23
 class CopyRegistrationDetailsCommandHandler extends CommandHandler
24 24
 {
25
-    /**
26
-     * @var CopyRegistrationService $copy_registration_service
27
-     */
28
-    private $copy_registration_service;
25
+	/**
26
+	 * @var CopyRegistrationService $copy_registration_service
27
+	 */
28
+	private $copy_registration_service;
29 29
 
30 30
 
31
-    /**
32
-     * Command constructor
33
-     *
34
-     * @param CopyRegistrationService $copy_registration_service
35
-     */
36
-    public function __construct(CopyRegistrationService $copy_registration_service)
37
-    {
38
-        defined('EVENT_ESPRESSO_VERSION') || exit;
39
-        $this->copy_registration_service = $copy_registration_service;
40
-    }
31
+	/**
32
+	 * Command constructor
33
+	 *
34
+	 * @param CopyRegistrationService $copy_registration_service
35
+	 */
36
+	public function __construct(CopyRegistrationService $copy_registration_service)
37
+	{
38
+		defined('EVENT_ESPRESSO_VERSION') || exit;
39
+		$this->copy_registration_service = $copy_registration_service;
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @param CommandInterface|CopyRegistrationDetailsCommand $command
45
-     * @return boolean
46
-     * @throws InvalidEntityException
47
-     * @throws EE_Error
48
-     * @throws EntityNotFoundException
49
-     * @throws UnexpectedEntityException
50
-     * @throws RuntimeException
51
-     */
52
-    public function handle(CommandInterface $command)
53
-    {
54
-        return $this->copy_registration_service->copyRegistrationDetails(
55
-            $command->targetRegistration(),
56
-            $command->registrationToCopy()
57
-        );
58
-    }
43
+	/**
44
+	 * @param CommandInterface|CopyRegistrationDetailsCommand $command
45
+	 * @return boolean
46
+	 * @throws InvalidEntityException
47
+	 * @throws EE_Error
48
+	 * @throws EntityNotFoundException
49
+	 * @throws UnexpectedEntityException
50
+	 * @throws RuntimeException
51
+	 */
52
+	public function handle(CommandInterface $command)
53
+	{
54
+		return $this->copy_registration_service->copyRegistrationDetails(
55
+			$command->targetRegistration(),
56
+			$command->registrationToCopy()
57
+		);
58
+	}
59 59
 }
Please login to merge, or discard this patch.
core/services/commands/middleware/LocateMovedCommands.php 1 patch
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -35,189 +35,189 @@
 block discarded – undo
35 35
  */
36 36
 class LocateMovedCommands implements CommandBusMiddlewareInterface
37 37
 {
38
-    /**
39
-     * @param CommandInterface $command
40
-     * @param Closure          $next
41
-     * @return mixed
42
-     * @throws EE_Error
43
-     */
44
-    public function handle(CommandInterface $command, Closure $next)
45
-    {
46
-        $command_class = get_class($command);
47
-        switch ($command_class) {
48
-            case 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommand':
49
-                $command = $this->getCreateAttendeeCommand($command);
50
-                break;
51
-            case 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommand':
52
-                $command = $this->getCancelRegistrationAndTicketLineItemCommand($command);
53
-                break;
54
-            case 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand':
55
-                $command = $this->getCopyRegistrationDetailsCommand($command);
56
-                break;
57
-            case 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand':
58
-                $command = $this->getCopyRegistrationPaymentsCommand($command);
59
-                break;
60
-            case 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand':
61
-                $command = $this->getCreateRegistrationCommand($command);
62
-                break;
63
-            case 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommand':
64
-                $command = $this->getUpdateRegistrationAndTransactionAfterChangeCommand($command);
65
-                break;
66
-            case 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommand':
67
-                $command = $this->getCancelTicketLineItemCommand($command);
68
-                break;
69
-            case 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand':
70
-                $command = $this->getCreateTicketLineItemCommand($command);
71
-                break;
72
-            case 'EventEspresso\core\services\commands\transaction\CreateTransactionCommand':
73
-                $command = $this->getCreateTransactionCommand($command);
74
-                break;
75
-        }
76
-        return $next($command);
77
-    }
78
-
79
-
80
-    /**
81
-     * @param OldCreateAttendeeCommand|CommandInterface $command
82
-     * @return CreateAttendeeCommand|OldCreateAttendeeCommand
83
-     */
84
-    private function getCreateAttendeeCommand(OldCreateAttendeeCommand $command)
85
-    {
86
-        return class_exists('EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommand')
87
-            ? new CreateAttendeeCommand(
88
-                $command->attendeeDetails(),
89
-                $command->registration()
90
-            )
91
-            : $command;
92
-    }
93
-
94
-
95
-    /**
96
-     * @param OldCancelRegistrationAndTicketLineItemCommand|CommandInterface $command
97
-     * @return CancelRegistrationAndTicketLineItemCommand|OldCancelRegistrationAndTicketLineItemCommand
98
-     */
99
-    private function getCancelRegistrationAndTicketLineItemCommand(
100
-        OldCancelRegistrationAndTicketLineItemCommand $command
101
-    ) {
102
-        return class_exists('EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommand')
103
-            ? new CancelRegistrationAndTicketLineItemCommand($command->registration())
104
-            : $command;
105
-    }
106
-
107
-
108
-    /**
109
-     * @param OldCopyRegistrationDetailsCommand|CommandInterface $command
110
-     * @return CopyRegistrationDetailsCommand|OldCopyRegistrationDetailsCommand
111
-     */
112
-    private function getCopyRegistrationDetailsCommand(
113
-        OldCopyRegistrationDetailsCommand $command
114
-    ) {
115
-        return class_exists('EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommand')
116
-            ? new CopyRegistrationDetailsCommand(
117
-                $command->targetRegistration(),
118
-                $command->registrationToCopy()
119
-            )
120
-            : $command;
121
-    }
122
-
123
-
124
-    /**
125
-     * @param OldCopyRegistrationPaymentsCommand|CommandInterface $command
126
-     * @return CopyRegistrationPaymentsCommand|OldCopyRegistrationPaymentsCommand
127
-     */
128
-    private function getCopyRegistrationPaymentsCommand(
129
-        OldCopyRegistrationPaymentsCommand $command
130
-    ) {
131
-        return class_exists('EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommand')
132
-            ? new CopyRegistrationPaymentsCommand(
133
-                $command->targetRegistration(),
134
-                $command->registrationToCopy()
135
-            )
136
-            : $command;
137
-    }
138
-
139
-
140
-    /**
141
-     * @param OldCreateRegistrationCommand|CommandInterface $command
142
-     * @return CreateRegistrationCommand|OldCreateRegistrationCommand
143
-     * @throws EE_Error
144
-     */
145
-    private function getCreateRegistrationCommand(
146
-        OldCreateRegistrationCommand $command
147
-    ) {
148
-        return class_exists('EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommand')
149
-            ? new CreateRegistrationCommand(
150
-                $command->transaction(),
151
-                $command->ticketLineItem(),
152
-                $command->regCount(),
153
-                $command->regGroupSize(),
154
-                $command->regStatus(),
155
-                $command->ticket()
156
-            )
157
-            : $command;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param OldUpdateRegistrationAndTransactionAfterChangeCommand|CommandInterface $command
163
-     * @return UpdateRegistrationAndTransactionAfterChangeCommand|OldUpdateRegistrationAndTransactionAfterChangeCommand
164
-     */
165
-    private function getUpdateRegistrationAndTransactionAfterChangeCommand(
166
-        OldUpdateRegistrationAndTransactionAfterChangeCommand $command
167
-    ) {
168
-        return class_exists('EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommand')
169
-            ? new UpdateRegistrationAndTransactionAfterChangeCommand($command->registration())
170
-            : $command;
171
-    }
172
-
173
-
174
-    /**
175
-     * @param OldCancelTicketLineItemCommand|CommandInterface $command
176
-     * @return CancelTicketLineItemCommand|OldCancelTicketLineItemCommand
177
-     */
178
-    private function getCancelTicketLineItemCommand(
179
-        OldCancelTicketLineItemCommand $command
180
-    ) {
181
-        return class_exists('EventEspresso\core\domain\services\commands\ticket\CancelTicketLineItemCommand')
182
-            ? new CancelTicketLineItemCommand(
183
-                $command->transaction(),
184
-                $command->ticket(),
185
-                $command->quantity(),
186
-                $command->ticketLineItem()
187
-            )
188
-            : $command;
189
-    }
190
-
191
-
192
-    /**
193
-     * @param OldCreateTicketLineItemCommand|CommandInterface $command
194
-     * @return CreateTicketLineItemCommand|OldCreateTicketLineItemCommand
195
-     */
196
-    private function getCreateTicketLineItemCommand(
197
-        OldCreateTicketLineItemCommand $command
198
-    ) {
199
-        return class_exists('EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommand')
200
-            ? new CreateTicketLineItemCommand(
201
-                $command->transaction(),
202
-                $command->ticket(),
203
-                $command->quantity()
204
-            )
205
-            : $command;
206
-    }
207
-
208
-
209
-    /**
210
-     * @param OldCreateTransactionCommand|CommandInterface $command
211
-     * @return CreateTransactionCommand|OldCreateTransactionCommand
212
-     */
213
-    private function getCreateTransactionCommand(
214
-        OldCreateTransactionCommand $command
215
-    ) {
216
-        return class_exists('EventEspresso\core\domain\services\commands\transaction\CreateTransactionCommand')
217
-            ? new CreateTransactionCommand(
218
-                $command->checkout(),
219
-                $command->transactionDetails()
220
-            )
221
-            : $command;
222
-    }
38
+	/**
39
+	 * @param CommandInterface $command
40
+	 * @param Closure          $next
41
+	 * @return mixed
42
+	 * @throws EE_Error
43
+	 */
44
+	public function handle(CommandInterface $command, Closure $next)
45
+	{
46
+		$command_class = get_class($command);
47
+		switch ($command_class) {
48
+			case 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommand':
49
+				$command = $this->getCreateAttendeeCommand($command);
50
+				break;
51
+			case 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommand':
52
+				$command = $this->getCancelRegistrationAndTicketLineItemCommand($command);
53
+				break;
54
+			case 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand':
55
+				$command = $this->getCopyRegistrationDetailsCommand($command);
56
+				break;
57
+			case 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand':
58
+				$command = $this->getCopyRegistrationPaymentsCommand($command);
59
+				break;
60
+			case 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand':
61
+				$command = $this->getCreateRegistrationCommand($command);
62
+				break;
63
+			case 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommand':
64
+				$command = $this->getUpdateRegistrationAndTransactionAfterChangeCommand($command);
65
+				break;
66
+			case 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommand':
67
+				$command = $this->getCancelTicketLineItemCommand($command);
68
+				break;
69
+			case 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand':
70
+				$command = $this->getCreateTicketLineItemCommand($command);
71
+				break;
72
+			case 'EventEspresso\core\services\commands\transaction\CreateTransactionCommand':
73
+				$command = $this->getCreateTransactionCommand($command);
74
+				break;
75
+		}
76
+		return $next($command);
77
+	}
78
+
79
+
80
+	/**
81
+	 * @param OldCreateAttendeeCommand|CommandInterface $command
82
+	 * @return CreateAttendeeCommand|OldCreateAttendeeCommand
83
+	 */
84
+	private function getCreateAttendeeCommand(OldCreateAttendeeCommand $command)
85
+	{
86
+		return class_exists('EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommand')
87
+			? new CreateAttendeeCommand(
88
+				$command->attendeeDetails(),
89
+				$command->registration()
90
+			)
91
+			: $command;
92
+	}
93
+
94
+
95
+	/**
96
+	 * @param OldCancelRegistrationAndTicketLineItemCommand|CommandInterface $command
97
+	 * @return CancelRegistrationAndTicketLineItemCommand|OldCancelRegistrationAndTicketLineItemCommand
98
+	 */
99
+	private function getCancelRegistrationAndTicketLineItemCommand(
100
+		OldCancelRegistrationAndTicketLineItemCommand $command
101
+	) {
102
+		return class_exists('EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommand')
103
+			? new CancelRegistrationAndTicketLineItemCommand($command->registration())
104
+			: $command;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @param OldCopyRegistrationDetailsCommand|CommandInterface $command
110
+	 * @return CopyRegistrationDetailsCommand|OldCopyRegistrationDetailsCommand
111
+	 */
112
+	private function getCopyRegistrationDetailsCommand(
113
+		OldCopyRegistrationDetailsCommand $command
114
+	) {
115
+		return class_exists('EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommand')
116
+			? new CopyRegistrationDetailsCommand(
117
+				$command->targetRegistration(),
118
+				$command->registrationToCopy()
119
+			)
120
+			: $command;
121
+	}
122
+
123
+
124
+	/**
125
+	 * @param OldCopyRegistrationPaymentsCommand|CommandInterface $command
126
+	 * @return CopyRegistrationPaymentsCommand|OldCopyRegistrationPaymentsCommand
127
+	 */
128
+	private function getCopyRegistrationPaymentsCommand(
129
+		OldCopyRegistrationPaymentsCommand $command
130
+	) {
131
+		return class_exists('EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommand')
132
+			? new CopyRegistrationPaymentsCommand(
133
+				$command->targetRegistration(),
134
+				$command->registrationToCopy()
135
+			)
136
+			: $command;
137
+	}
138
+
139
+
140
+	/**
141
+	 * @param OldCreateRegistrationCommand|CommandInterface $command
142
+	 * @return CreateRegistrationCommand|OldCreateRegistrationCommand
143
+	 * @throws EE_Error
144
+	 */
145
+	private function getCreateRegistrationCommand(
146
+		OldCreateRegistrationCommand $command
147
+	) {
148
+		return class_exists('EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommand')
149
+			? new CreateRegistrationCommand(
150
+				$command->transaction(),
151
+				$command->ticketLineItem(),
152
+				$command->regCount(),
153
+				$command->regGroupSize(),
154
+				$command->regStatus(),
155
+				$command->ticket()
156
+			)
157
+			: $command;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param OldUpdateRegistrationAndTransactionAfterChangeCommand|CommandInterface $command
163
+	 * @return UpdateRegistrationAndTransactionAfterChangeCommand|OldUpdateRegistrationAndTransactionAfterChangeCommand
164
+	 */
165
+	private function getUpdateRegistrationAndTransactionAfterChangeCommand(
166
+		OldUpdateRegistrationAndTransactionAfterChangeCommand $command
167
+	) {
168
+		return class_exists('EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommand')
169
+			? new UpdateRegistrationAndTransactionAfterChangeCommand($command->registration())
170
+			: $command;
171
+	}
172
+
173
+
174
+	/**
175
+	 * @param OldCancelTicketLineItemCommand|CommandInterface $command
176
+	 * @return CancelTicketLineItemCommand|OldCancelTicketLineItemCommand
177
+	 */
178
+	private function getCancelTicketLineItemCommand(
179
+		OldCancelTicketLineItemCommand $command
180
+	) {
181
+		return class_exists('EventEspresso\core\domain\services\commands\ticket\CancelTicketLineItemCommand')
182
+			? new CancelTicketLineItemCommand(
183
+				$command->transaction(),
184
+				$command->ticket(),
185
+				$command->quantity(),
186
+				$command->ticketLineItem()
187
+			)
188
+			: $command;
189
+	}
190
+
191
+
192
+	/**
193
+	 * @param OldCreateTicketLineItemCommand|CommandInterface $command
194
+	 * @return CreateTicketLineItemCommand|OldCreateTicketLineItemCommand
195
+	 */
196
+	private function getCreateTicketLineItemCommand(
197
+		OldCreateTicketLineItemCommand $command
198
+	) {
199
+		return class_exists('EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommand')
200
+			? new CreateTicketLineItemCommand(
201
+				$command->transaction(),
202
+				$command->ticket(),
203
+				$command->quantity()
204
+			)
205
+			: $command;
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param OldCreateTransactionCommand|CommandInterface $command
211
+	 * @return CreateTransactionCommand|OldCreateTransactionCommand
212
+	 */
213
+	private function getCreateTransactionCommand(
214
+		OldCreateTransactionCommand $command
215
+	) {
216
+		return class_exists('EventEspresso\core\domain\services\commands\transaction\CreateTransactionCommand')
217
+			? new CreateTransactionCommand(
218
+				$command->checkout(),
219
+				$command->transactionDetails()
220
+			)
221
+			: $command;
222
+	}
223 223
 }
Please login to merge, or discard this patch.
core/services/commands/CommandBusInterface.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@
 block discarded – undo
9 9
  */
10 10
 interface CommandBusInterface
11 11
 {
12
-    /**
13
-     * @return CommandHandlerManagerInterface
14
-     */
15
-    public function getCommandHandlerManager();
12
+	/**
13
+	 * @return CommandHandlerManagerInterface
14
+	 */
15
+	public function getCommandHandlerManager();
16 16
 
17
-    /**
18
-     * @param CommandInterface $command
19
-     * @return mixed
20
-     */
21
-    public function execute($command);
17
+	/**
18
+	 * @param CommandInterface $command
19
+	 * @return mixed
20
+	 */
21
+	public function execute($command);
22 22
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketDetails.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function getShowHideLinks(): string
119 119
     {
120
-        if (! $this->showTicketDetails()) {
120
+        if ( ! $this->showTicketDetails()) {
121 121
             return '';
122 122
         }
123 123
         return EEH_HTML::link(
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
             "display-{$this->cssId()}",
133 133
             'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
134 134
             '',
135
-            'rel="' . $this->cssId() . '"'
136
-        ) . EEH_HTML::link(
135
+            'rel="'.$this->cssId().'"'
136
+        ).EEH_HTML::link(
137 137
             '',
138 138
             sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), ' '),
139 139
             esc_attr(
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
             "hide-{$this->cssId()}",
146 146
             'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
147 147
             'display:none;',
148
-            'rel="' . $this->cssId() . '"'
148
+            'rel="'.$this->cssId().'"'
149 149
         );
150 150
     }
151 151
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                                                          'FHEE__ticket_selector_chart_template__display_ticket_price_details',
192 192
                                                          true
193 193
                                                      );
194
-        $template_args['price_breakdown_heading']  = apply_filters(
194
+        $template_args['price_breakdown_heading'] = apply_filters(
195 195
             'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
196 196
             esc_html__('Price', 'event_espresso')
197 197
         );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         return EEH_Template::locate_template(
203 203
             apply_filters(
204 204
                 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
205
-                TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
205
+                TICKET_SELECTOR_TEMPLATES_PATH.'ticket_details.template.php',
206 206
                 $this->ticket
207 207
             ),
208 208
             $template_args
Please login to merge, or discard this patch.
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -19,193 +19,193 @@
 block discarded – undo
19 19
  */
20 20
 class TicketDetails
21 21
 {
22
-    /**
23
-     * @var EE_Ticket
24
-     */
25
-    protected $ticket;
26
-
27
-    /**
28
-     * @var EE_Ticket_Selector_Config
29
-     */
30
-    protected $template_settings;
31
-
32
-    /**
33
-     * @var string $date_format
34
-     */
35
-    protected $date_format;
36
-
37
-    /**
38
-     * @var string $time_format
39
-     */
40
-    protected $time_format;
41
-
42
-    /**
43
-     * @var bool $event_is_expired
44
-     */
45
-    protected $event_is_expired;
46
-
47
-
48
-    /**
49
-     * TicketDetails constructor.
50
-     *
51
-     * @param EE_Ticket                 $ticket
52
-     * @param EE_Ticket_Selector_Config $template_settings
53
-     * @param array                     $template_args
54
-     */
55
-    public function __construct(
56
-        EE_Ticket $ticket,
57
-        EE_Ticket_Selector_Config $template_settings,
58
-        array $template_args
59
-    ) {
60
-        $this->ticket            = $ticket;
61
-        $this->template_settings = $template_settings;
62
-        $this->date_format       = $template_args['date_format'];
63
-        $this->time_format       = $template_args['time_format'];
64
-        $this->event_is_expired  = $template_args['event_is_expired'];
65
-    }
66
-
67
-
68
-    /**
69
-     * @return EE_Ticket
70
-     */
71
-    public function getTicket(): EE_Ticket
72
-    {
73
-        return $this->ticket;
74
-    }
75
-
76
-
77
-    /**
78
-     * @return bool
79
-     */
80
-    public function showTicketDetails(): bool
81
-    {
82
-        return $this->template_settings->show_ticket_details;
83
-    }
84
-
85
-
86
-    /**
87
-     * @return EE_Ticket_Selector_Config
88
-     */
89
-    public function getTemplateSettings(): EE_Ticket_Selector_Config
90
-    {
91
-        return $this->template_settings;
92
-    }
93
-
94
-
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getDateFormat(): string
99
-    {
100
-        return $this->date_format;
101
-    }
102
-
103
-
104
-    /**
105
-     * @return string
106
-     */
107
-    public function getTimeFormat(): string
108
-    {
109
-        return $this->time_format;
110
-    }
111
-
112
-
113
-    /**
114
-     * @return string
115
-     * @throws EE_Error
116
-     * @throws ReflectionException
117
-     */
118
-    public function getShowHideLinks(): string
119
-    {
120
-        if (! $this->showTicketDetails()) {
121
-            return '';
122
-        }
123
-        return EEH_HTML::link(
124
-            '',
125
-            sprintf(esc_html__('show%1$sdetails%1$s+', 'event_espresso'), ' '),
126
-            esc_attr(
127
-                apply_filters(
128
-                    'FHEE__ticket_selector_chart_template__show_ticket_details_link_title',
129
-                    esc_html__('click to show additional ticket details', 'event_espresso')
130
-                )
131
-            ),
132
-            "display-{$this->cssId()}",
133
-            'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
134
-            '',
135
-            'rel="' . $this->cssId() . '"'
136
-        ) . EEH_HTML::link(
137
-            '',
138
-            sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), ' '),
139
-            esc_attr(
140
-                apply_filters(
141
-                    'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title',
142
-                    esc_html__('click to hide additional ticket details', 'event_espresso')
143
-                )
144
-            ),
145
-            "hide-{$this->cssId()}",
146
-            'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
147
-            'display:none;',
148
-            'rel="' . $this->cssId() . '"'
149
-        );
150
-    }
151
-
152
-
153
-    /**
154
-     * @return string
155
-     * @throws EE_Error
156
-     * @throws ReflectionException
157
-     */
158
-    public function cssId(): string
159
-    {
160
-        return apply_filters(
161
-            'FHEE__ticket_selector_chart_template__ticket_details_css_id',
162
-            "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}"
163
-        );
164
-    }
165
-
166
-
167
-    /**
168
-     * @param float     $ticket_price
169
-     * @param int|float $remaining
170
-     * @param int       $cols
171
-     * @return string
172
-     * @throws EE_Error
173
-     * @throws ReflectionException
174
-     */
175
-    public function display(
176
-        float $ticket_price = 0.00,
177
-        $remaining = EE_INF,
178
-        int $cols = 2
179
-    ): string {
180
-        $template_args                             = [];
181
-        $template_args['ticket']                   = $this->ticket;
182
-        $template_args['ticket_price']             = $ticket_price;
183
-        $template_args['remaining']                = $remaining;
184
-        $template_args['cols']                     = $cols;
185
-        $template_args['show_ticket_details']      = $this->template_settings->show_ticket_details;
186
-        $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns;
187
-        $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details');
188
-        $template_args['ticket_details_css_id']    = $this->cssId();
189
-        $template_args['display_ticket_price']     = $ticket_price !== 0.0
190
-                                                     && apply_filters(
191
-                                                         'FHEE__ticket_selector_chart_template__display_ticket_price_details',
192
-                                                         true
193
-                                                     );
194
-        $template_args['price_breakdown_heading']  = apply_filters(
195
-            'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
196
-            esc_html__('Price', 'event_espresso')
197
-        );
198
-        $template_args['date_format']              = $this->date_format;
199
-        $template_args['time_format']              = $this->time_format;
200
-        $template_args['event_is_expired']         = $this->event_is_expired;
201
-
202
-        return EEH_Template::locate_template(
203
-            apply_filters(
204
-                'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
205
-                TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
206
-                $this->ticket
207
-            ),
208
-            $template_args
209
-        );
210
-    }
22
+	/**
23
+	 * @var EE_Ticket
24
+	 */
25
+	protected $ticket;
26
+
27
+	/**
28
+	 * @var EE_Ticket_Selector_Config
29
+	 */
30
+	protected $template_settings;
31
+
32
+	/**
33
+	 * @var string $date_format
34
+	 */
35
+	protected $date_format;
36
+
37
+	/**
38
+	 * @var string $time_format
39
+	 */
40
+	protected $time_format;
41
+
42
+	/**
43
+	 * @var bool $event_is_expired
44
+	 */
45
+	protected $event_is_expired;
46
+
47
+
48
+	/**
49
+	 * TicketDetails constructor.
50
+	 *
51
+	 * @param EE_Ticket                 $ticket
52
+	 * @param EE_Ticket_Selector_Config $template_settings
53
+	 * @param array                     $template_args
54
+	 */
55
+	public function __construct(
56
+		EE_Ticket $ticket,
57
+		EE_Ticket_Selector_Config $template_settings,
58
+		array $template_args
59
+	) {
60
+		$this->ticket            = $ticket;
61
+		$this->template_settings = $template_settings;
62
+		$this->date_format       = $template_args['date_format'];
63
+		$this->time_format       = $template_args['time_format'];
64
+		$this->event_is_expired  = $template_args['event_is_expired'];
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return EE_Ticket
70
+	 */
71
+	public function getTicket(): EE_Ticket
72
+	{
73
+		return $this->ticket;
74
+	}
75
+
76
+
77
+	/**
78
+	 * @return bool
79
+	 */
80
+	public function showTicketDetails(): bool
81
+	{
82
+		return $this->template_settings->show_ticket_details;
83
+	}
84
+
85
+
86
+	/**
87
+	 * @return EE_Ticket_Selector_Config
88
+	 */
89
+	public function getTemplateSettings(): EE_Ticket_Selector_Config
90
+	{
91
+		return $this->template_settings;
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getDateFormat(): string
99
+	{
100
+		return $this->date_format;
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return string
106
+	 */
107
+	public function getTimeFormat(): string
108
+	{
109
+		return $this->time_format;
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return string
115
+	 * @throws EE_Error
116
+	 * @throws ReflectionException
117
+	 */
118
+	public function getShowHideLinks(): string
119
+	{
120
+		if (! $this->showTicketDetails()) {
121
+			return '';
122
+		}
123
+		return EEH_HTML::link(
124
+			'',
125
+			sprintf(esc_html__('show%1$sdetails%1$s+', 'event_espresso'), ' '),
126
+			esc_attr(
127
+				apply_filters(
128
+					'FHEE__ticket_selector_chart_template__show_ticket_details_link_title',
129
+					esc_html__('click to show additional ticket details', 'event_espresso')
130
+				)
131
+			),
132
+			"display-{$this->cssId()}",
133
+			'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
134
+			'',
135
+			'rel="' . $this->cssId() . '"'
136
+		) . EEH_HTML::link(
137
+			'',
138
+			sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), ' '),
139
+			esc_attr(
140
+				apply_filters(
141
+					'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title',
142
+					esc_html__('click to hide additional ticket details', 'event_espresso')
143
+				)
144
+			),
145
+			"hide-{$this->cssId()}",
146
+			'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
147
+			'display:none;',
148
+			'rel="' . $this->cssId() . '"'
149
+		);
150
+	}
151
+
152
+
153
+	/**
154
+	 * @return string
155
+	 * @throws EE_Error
156
+	 * @throws ReflectionException
157
+	 */
158
+	public function cssId(): string
159
+	{
160
+		return apply_filters(
161
+			'FHEE__ticket_selector_chart_template__ticket_details_css_id',
162
+			"tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}"
163
+		);
164
+	}
165
+
166
+
167
+	/**
168
+	 * @param float     $ticket_price
169
+	 * @param int|float $remaining
170
+	 * @param int       $cols
171
+	 * @return string
172
+	 * @throws EE_Error
173
+	 * @throws ReflectionException
174
+	 */
175
+	public function display(
176
+		float $ticket_price = 0.00,
177
+		$remaining = EE_INF,
178
+		int $cols = 2
179
+	): string {
180
+		$template_args                             = [];
181
+		$template_args['ticket']                   = $this->ticket;
182
+		$template_args['ticket_price']             = $ticket_price;
183
+		$template_args['remaining']                = $remaining;
184
+		$template_args['cols']                     = $cols;
185
+		$template_args['show_ticket_details']      = $this->template_settings->show_ticket_details;
186
+		$template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns;
187
+		$template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details');
188
+		$template_args['ticket_details_css_id']    = $this->cssId();
189
+		$template_args['display_ticket_price']     = $ticket_price !== 0.0
190
+													 && apply_filters(
191
+														 'FHEE__ticket_selector_chart_template__display_ticket_price_details',
192
+														 true
193
+													 );
194
+		$template_args['price_breakdown_heading']  = apply_filters(
195
+			'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
196
+			esc_html__('Price', 'event_espresso')
197
+		);
198
+		$template_args['date_format']              = $this->date_format;
199
+		$template_args['time_format']              = $this->time_format;
200
+		$template_args['event_is_expired']         = $this->event_is_expired;
201
+
202
+		return EEH_Template::locate_template(
203
+			apply_filters(
204
+				'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
205
+				TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
206
+				$this->ticket
207
+			),
208
+			$template_args
209
+		);
210
+	}
211 211
 }
Please login to merge, or discard this patch.
core/services/commands/CommandBus.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -33,75 +33,75 @@
 block discarded – undo
33 33
  */
34 34
 class CommandBus implements CommandBusInterface
35 35
 {
36
-    /**
37
-     * @type CommandHandlerManagerInterface $command_handler_manager
38
-     */
39
-    private $command_handler_manager;
36
+	/**
37
+	 * @type CommandHandlerManagerInterface $command_handler_manager
38
+	 */
39
+	private $command_handler_manager;
40 40
 
41
-    /**
42
-     * @type CommandBusMiddlewareInterface[] $command_bus_middleware
43
-     */
44
-    private $command_bus_middleware;
41
+	/**
42
+	 * @type CommandBusMiddlewareInterface[] $command_bus_middleware
43
+	 */
44
+	private $command_bus_middleware;
45 45
 
46 46
 
47
-    /**
48
-     * CommandBus constructor
49
-     *
50
-     * @param CommandHandlerManagerInterface  $command_handler_manager
51
-     * @param CommandBusMiddlewareInterface[] $command_bus_middleware
52
-     */
53
-    public function __construct(
54
-        CommandHandlerManagerInterface $command_handler_manager,
55
-        array $command_bus_middleware = array()
56
-    ) {
57
-        $this->command_handler_manager = $command_handler_manager;
58
-        $this->command_bus_middleware = is_array($command_bus_middleware)
59
-            ? $command_bus_middleware
60
-            : array($command_bus_middleware);
61
-    }
47
+	/**
48
+	 * CommandBus constructor
49
+	 *
50
+	 * @param CommandHandlerManagerInterface  $command_handler_manager
51
+	 * @param CommandBusMiddlewareInterface[] $command_bus_middleware
52
+	 */
53
+	public function __construct(
54
+		CommandHandlerManagerInterface $command_handler_manager,
55
+		array $command_bus_middleware = array()
56
+	) {
57
+		$this->command_handler_manager = $command_handler_manager;
58
+		$this->command_bus_middleware = is_array($command_bus_middleware)
59
+			? $command_bus_middleware
60
+			: array($command_bus_middleware);
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * @return CommandHandlerManagerInterface
66
-     */
67
-    public function getCommandHandlerManager()
68
-    {
69
-        return $this->command_handler_manager;
70
-    }
64
+	/**
65
+	 * @return CommandHandlerManagerInterface
66
+	 */
67
+	public function getCommandHandlerManager()
68
+	{
69
+		return $this->command_handler_manager;
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * @param CommandInterface $command
75
-     * @return mixed
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidCommandBusMiddlewareException
78
-     */
79
-    public function execute($command)
80
-    {
81
-        if (! $command instanceof CommandInterface) {
82
-            throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
83
-        }
84
-        // we're going to add the Command Handler as a callable
85
-        // that will get run at the end of our middleware stack
86
-        // can't pass $this to a Closure, so use a named variable
87
-        $command_bus = $this;
88
-        $middleware = static function ($command) use ($command_bus) {
89
-            return $command_bus->getCommandHandlerManager()
90
-                               ->getCommandHandler($command, $command_bus)
91
-                               ->verify($command)
92
-                               ->handle($command);
93
-        };
94
-        $command_bus_middleware_array = $this->command_bus_middleware;
95
-        // now build the rest of the middleware stack
96
-        while ($command_bus_middleware = array_pop($command_bus_middleware_array)) {
97
-            if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
98
-                throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
99
-            }
100
-            $middleware = static function ($command) use ($command_bus_middleware, $middleware) {
101
-                return $command_bus_middleware->handle($command, $middleware);
102
-            };
103
-        }
104
-        // and finally, pass the command into the stack and return the results
105
-        return $middleware($command);
106
-    }
73
+	/**
74
+	 * @param CommandInterface $command
75
+	 * @return mixed
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidCommandBusMiddlewareException
78
+	 */
79
+	public function execute($command)
80
+	{
81
+		if (! $command instanceof CommandInterface) {
82
+			throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
83
+		}
84
+		// we're going to add the Command Handler as a callable
85
+		// that will get run at the end of our middleware stack
86
+		// can't pass $this to a Closure, so use a named variable
87
+		$command_bus = $this;
88
+		$middleware = static function ($command) use ($command_bus) {
89
+			return $command_bus->getCommandHandlerManager()
90
+							   ->getCommandHandler($command, $command_bus)
91
+							   ->verify($command)
92
+							   ->handle($command);
93
+		};
94
+		$command_bus_middleware_array = $this->command_bus_middleware;
95
+		// now build the rest of the middleware stack
96
+		while ($command_bus_middleware = array_pop($command_bus_middleware_array)) {
97
+			if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
98
+				throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
99
+			}
100
+			$middleware = static function ($command) use ($command_bus_middleware, $middleware) {
101
+				return $command_bus_middleware->handle($command, $middleware);
102
+			};
103
+		}
104
+		// and finally, pass the command into the stack and return the results
105
+		return $middleware($command);
106
+	}
107 107
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function execute($command)
80 80
     {
81
-        if (! $command instanceof CommandInterface) {
82
-            throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
81
+        if ( ! $command instanceof CommandInterface) {
82
+            throw new InvalidDataTypeException(__METHOD__.'( $command )', $command, 'CommandInterface');
83 83
         }
84 84
         // we're going to add the Command Handler as a callable
85 85
         // that will get run at the end of our middleware stack
86 86
         // can't pass $this to a Closure, so use a named variable
87 87
         $command_bus = $this;
88
-        $middleware = static function ($command) use ($command_bus) {
88
+        $middleware = static function($command) use ($command_bus) {
89 89
             return $command_bus->getCommandHandlerManager()
90 90
                                ->getCommandHandler($command, $command_bus)
91 91
                                ->verify($command)
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
         $command_bus_middleware_array = $this->command_bus_middleware;
95 95
         // now build the rest of the middleware stack
96 96
         while ($command_bus_middleware = array_pop($command_bus_middleware_array)) {
97
-            if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
97
+            if ( ! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
98 98
                 throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
99 99
             }
100
-            $middleware = static function ($command) use ($command_bus_middleware, $middleware) {
100
+            $middleware = static function($command) use ($command_bus_middleware, $middleware) {
101 101
                 return $command_bus_middleware->handle($command, $middleware);
102 102
             };
103 103
         }
Please login to merge, or discard this patch.
core/services/commands/CommandHandlerManager.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -17,83 +17,83 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class CommandHandlerManager implements CommandHandlerManagerInterface
19 19
 {
20
-    /**
21
-     * @var CommandHandlerInterface[] $command_handlers
22
-     */
23
-    protected $command_handlers;
20
+	/**
21
+	 * @var CommandHandlerInterface[] $command_handlers
22
+	 */
23
+	protected $command_handlers;
24 24
 
25
-    /**
26
-     * @type LoaderInterface $loader
27
-     */
28
-    private $loader;
25
+	/**
26
+	 * @type LoaderInterface $loader
27
+	 */
28
+	private $loader;
29 29
 
30 30
 
31
-    /**
32
-     * CommandHandlerManager constructor
33
-     *
34
-     * @param LoaderInterface $loader
35
-     */
36
-    public function __construct(LoaderInterface $loader)
37
-    {
38
-        $this->loader = $loader;
39
-    }
31
+	/**
32
+	 * CommandHandlerManager constructor
33
+	 *
34
+	 * @param LoaderInterface $loader
35
+	 */
36
+	public function __construct(LoaderInterface $loader)
37
+	{
38
+		$this->loader = $loader;
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * By default, Commands and CommandHandlers would normally
44
-     * reside in the same folder under the same namespace,
45
-     * and the names of the two classes would only differ in that
46
-     * one ends in "Command" and the other ends in "CommandHandler".
47
-     * However, if you wanted to utilize a CommandHandler from somewhere else,
48
-     * then this method allows you to add that CommandHandler and specify the FQCN
49
-     * (Fully Qualified ClassName) for the Command class that it should be used for.
50
-     * For example:
51
-     *      by default the "Vendor\some\namespace\DoSomethingCommand"
52
-     *      would resolve to using "Vendor\some\namespace\DoSomethingCommandHandler"
53
-     *      but if you wanted to instead process that commend using:
54
-     *      "Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler"
55
-     *      then the following code:
56
-     *      $CommandHandlerManager = $this->loader->getShared( 'CommandHandlerManagerInterface' );
57
-     *      $CommandHandlerManager->addCommandHandler(
58
-     *          new Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler(),
59
-     *          'Vendor\some\namespace\DoSomethingCommand'
60
-     *      );
61
-     *      would result in the alternate CommandHandler being used to process that Command
62
-     *
63
-     * !!! IMPORTANT !!!
64
-     * If overriding the default CommandHandler for a Command,
65
-     * be sure to also override CommandHandler::verify(),
66
-     * or else an Exception will be thrown when the CommandBus
67
-     * attempts to verify that the incoming Command matches the Handler
68
-     *
69
-     * @param CommandHandlerInterface $command_handler
70
-     * @param string                  $fqcn_for_command Fully Qualified ClassName for Command
71
-     * @return void
72
-     * @throws InvalidCommandHandlerException
73
-     */
74
-    public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = '')
75
-    {
76
-        $command = ! empty($fqcn_for_command)
77
-            ? $fqcn_for_command
78
-            : str_replace('CommandHandler', 'Command', get_class($command_handler));
79
-        if (empty($command)) {
80
-            throw new InvalidCommandHandlerException($command);
81
-        }
82
-        $this->command_handlers[ $command ] = $command_handler;
83
-    }
42
+	/**
43
+	 * By default, Commands and CommandHandlers would normally
44
+	 * reside in the same folder under the same namespace,
45
+	 * and the names of the two classes would only differ in that
46
+	 * one ends in "Command" and the other ends in "CommandHandler".
47
+	 * However, if you wanted to utilize a CommandHandler from somewhere else,
48
+	 * then this method allows you to add that CommandHandler and specify the FQCN
49
+	 * (Fully Qualified ClassName) for the Command class that it should be used for.
50
+	 * For example:
51
+	 *      by default the "Vendor\some\namespace\DoSomethingCommand"
52
+	 *      would resolve to using "Vendor\some\namespace\DoSomethingCommandHandler"
53
+	 *      but if you wanted to instead process that commend using:
54
+	 *      "Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler"
55
+	 *      then the following code:
56
+	 *      $CommandHandlerManager = $this->loader->getShared( 'CommandHandlerManagerInterface' );
57
+	 *      $CommandHandlerManager->addCommandHandler(
58
+	 *          new Vendor\a\totally\different\namespace\for\DoSomethingCommandHandler(),
59
+	 *          'Vendor\some\namespace\DoSomethingCommand'
60
+	 *      );
61
+	 *      would result in the alternate CommandHandler being used to process that Command
62
+	 *
63
+	 * !!! IMPORTANT !!!
64
+	 * If overriding the default CommandHandler for a Command,
65
+	 * be sure to also override CommandHandler::verify(),
66
+	 * or else an Exception will be thrown when the CommandBus
67
+	 * attempts to verify that the incoming Command matches the Handler
68
+	 *
69
+	 * @param CommandHandlerInterface $command_handler
70
+	 * @param string                  $fqcn_for_command Fully Qualified ClassName for Command
71
+	 * @return void
72
+	 * @throws InvalidCommandHandlerException
73
+	 */
74
+	public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = '')
75
+	{
76
+		$command = ! empty($fqcn_for_command)
77
+			? $fqcn_for_command
78
+			: str_replace('CommandHandler', 'Command', get_class($command_handler));
79
+		if (empty($command)) {
80
+			throw new InvalidCommandHandlerException($command);
81
+		}
82
+		$this->command_handlers[ $command ] = $command_handler;
83
+	}
84 84
 
85 85
 
86
-    /**
87
-     * @param CommandInterface    $command
88
-     * @param CommandBusInterface $command_bus
89
-     * @return mixed
90
-     * @throws DomainException
91
-     * @throws CommandHandlerNotFoundException
92
-     */
93
-    public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null)
94
-    {
95
-        $command_name = get_class($command);
96
-        /*
86
+	/**
87
+	 * @param CommandInterface    $command
88
+	 * @param CommandBusInterface $command_bus
89
+	 * @return mixed
90
+	 * @throws DomainException
91
+	 * @throws CommandHandlerNotFoundException
92
+	 */
93
+	public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null)
94
+	{
95
+		$command_name = get_class($command);
96
+		/*
97 97
          * Filters the Fully Qualified Class Name for the Command Handler
98 98
          * that will be used to handle the incoming Command
99 99
          *
@@ -106,35 +106,35 @@  discard block
 block discarded – undo
106 106
          * @param string "CommandHandler::class" Fully Qualified Class Name for the Command Handler
107 107
          * @param CommandInterface $command the actual Command instance
108 108
          */
109
-        $command_handler = apply_filters(
110
-            'FHEE__EventEspresso_core_services_commands_CommandHandlerManager__getCommandHandler__command_handler',
111
-            str_replace('Command', 'CommandHandler', $command_name),
112
-            $command
113
-        );
114
-        $handler = null;
115
-        // has a command handler already been set for this class ?
116
-        // if not, can we find one via the FQCN ?
117
-        if (isset($this->command_handlers[ $command_name ])) {
118
-            $handler = $this->command_handlers[ $command_name ];
119
-        } elseif (class_exists($command_handler)) {
120
-            $handler = $this->loader->getShared($command_handler);
121
-            $this->addCommandHandler($handler, $command_name);
122
-        }
123
-        // if Handler requires an instance of the CommandBus, but that has not yet been set
124
-        if ($handler instanceof CompositeCommandHandler && ! $handler->commandBus() instanceof CommandBusInterface) {
125
-            if (! $command_bus instanceof CommandBusInterface) {
126
-                throw new DomainException(
127
-                    esc_html__(
128
-                        'CompositeCommandHandler classes require an instance of the CommandBus.',
129
-                        'event_espresso'
130
-                    )
131
-                );
132
-            }
133
-            $handler->setCommandBus($command_bus);
134
-        }
135
-        if ($handler instanceof CommandHandlerInterface) {
136
-            return $handler;
137
-        }
138
-        throw new CommandHandlerNotFoundException($command_handler);
139
-    }
109
+		$command_handler = apply_filters(
110
+			'FHEE__EventEspresso_core_services_commands_CommandHandlerManager__getCommandHandler__command_handler',
111
+			str_replace('Command', 'CommandHandler', $command_name),
112
+			$command
113
+		);
114
+		$handler = null;
115
+		// has a command handler already been set for this class ?
116
+		// if not, can we find one via the FQCN ?
117
+		if (isset($this->command_handlers[ $command_name ])) {
118
+			$handler = $this->command_handlers[ $command_name ];
119
+		} elseif (class_exists($command_handler)) {
120
+			$handler = $this->loader->getShared($command_handler);
121
+			$this->addCommandHandler($handler, $command_name);
122
+		}
123
+		// if Handler requires an instance of the CommandBus, but that has not yet been set
124
+		if ($handler instanceof CompositeCommandHandler && ! $handler->commandBus() instanceof CommandBusInterface) {
125
+			if (! $command_bus instanceof CommandBusInterface) {
126
+				throw new DomainException(
127
+					esc_html__(
128
+						'CompositeCommandHandler classes require an instance of the CommandBus.',
129
+						'event_espresso'
130
+					)
131
+				);
132
+			}
133
+			$handler->setCommandBus($command_bus);
134
+		}
135
+		if ($handler instanceof CommandHandlerInterface) {
136
+			return $handler;
137
+		}
138
+		throw new CommandHandlerNotFoundException($command_handler);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         if (empty($command)) {
80 80
             throw new InvalidCommandHandlerException($command);
81 81
         }
82
-        $this->command_handlers[ $command ] = $command_handler;
82
+        $this->command_handlers[$command] = $command_handler;
83 83
     }
84 84
 
85 85
 
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
         $handler = null;
115 115
         // has a command handler already been set for this class ?
116 116
         // if not, can we find one via the FQCN ?
117
-        if (isset($this->command_handlers[ $command_name ])) {
118
-            $handler = $this->command_handlers[ $command_name ];
117
+        if (isset($this->command_handlers[$command_name])) {
118
+            $handler = $this->command_handlers[$command_name];
119 119
         } elseif (class_exists($command_handler)) {
120 120
             $handler = $this->loader->getShared($command_handler);
121 121
             $this->addCommandHandler($handler, $command_name);
122 122
         }
123 123
         // if Handler requires an instance of the CommandBus, but that has not yet been set
124 124
         if ($handler instanceof CompositeCommandHandler && ! $handler->commandBus() instanceof CommandBusInterface) {
125
-            if (! $command_bus instanceof CommandBusInterface) {
125
+            if ( ! $command_bus instanceof CommandBusInterface) {
126 126
                 throw new DomainException(
127 127
                     esc_html__(
128 128
                         'CompositeCommandHandler classes require an instance of the CommandBus.',
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Price_Types_List_Table.class.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function __construct($admin_page)
23 23
     {
24 24
         parent::__construct($admin_page);
25
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
25
+        require_once(EE_MODELS.'EEM_Price_Type.model.php');
26 26
         $this->_PRT = EEM_Price_Type::instance();
27 27
     }
28 28
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     protected function getActionUrl(EE_Price_Type $price_type, string $action): string
100 100
     {
101
-        if (! in_array($action, self::$actions)) {
101
+        if ( ! in_array($action, self::$actions)) {
102 102
             throw new DomainException(esc_html__('Invalid Action', 'event_espresso'));
103 103
         }
104 104
         return EE_Admin_Page::add_query_args_and_nonce(
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function column_id($item): string
134 134
     {
135
-        $content = '<span class="ee-entity-id">' . $item->ID() . '</span>';
136
-        $content .= '<span class="show-on-mobile-view-only">' . $this->column_name($item, false) . '</span>';
135
+        $content = '<span class="ee-entity-id">'.$item->ID().'</span>';
136
+        $content .= '<span class="show-on-mobile-view-only">'.$this->column_name($item, false).'</span>';
137 137
         return $this->columnContent('id', $content, 'end');
138 138
     }
139 139
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
             }
241 241
         }
242 242
 
243
-        $content = $prep_content ? $name_link . $this->row_actions($actions) : $name_link;
243
+        $content = $prep_content ? $name_link.$this->row_actions($actions) : $name_link;
244 244
         return $prep_content ? $this->columnContent('name', $content) : $content;
245 245
     }
246 246
 
Please login to merge, or discard this patch.
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -13,264 +13,264 @@
 block discarded – undo
13 13
  */
14 14
 class Price_Types_List_Table extends EE_Admin_List_Table
15 15
 {
16
-    /**
17
-     * @var Pricing_Admin_Page
18
-     */
19
-    protected EE_Admin_Page $_admin_page;
20
-
21
-    protected EEM_Price_Type $_PRT;
22
-
23
-
24
-    /**
25
-     * @throws EE_Error
26
-     * @throws ReflectionException
27
-     */
28
-    public function __construct($admin_page)
29
-    {
30
-        parent::__construct($admin_page);
31
-        require_once(EE_MODELS . 'EEM_Price_Type.model.php');
32
-        $this->_PRT = EEM_Price_Type::instance();
33
-    }
34
-
35
-
36
-    /**
37
-     * @throws ReflectionException
38
-     * @throws EE_Error
39
-     */
40
-    protected function _setup_data()
41
-    {
42
-        $trashed               = $this->_admin_page->get_view() == 'trashed';
43
-        $this->_data           = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
44
-        $this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true);
45
-        $this->_trashed_count  = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
46
-    }
47
-
48
-
49
-    protected function _set_properties()
50
-    {
51
-        $this->_wp_list_args = [
52
-            'singular' => esc_html__('price type', 'event_espresso'),
53
-            'plural'   => esc_html__('price types', 'event_espresso'),
54
-            'ajax'     => true,
55
-            'screen'   => $this->_admin_page->get_current_screen()->id,
56
-        ];
57
-
58
-        $this->_columns = [
59
-            'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
60
-            'id'        => esc_html__('ID', 'event_espresso'),
61
-            'name'      => esc_html__('Name', 'event_espresso'),
62
-            'base_type' => esc_html__('Base Type', 'event_espresso'),
63
-            'percent'   => sprintf(
64
-                               /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
65
-                esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'),
66
-                '',
67
-                '<span class="big-text">',
68
-                '</span>'
69
-            ),
70
-            'order'     => esc_html__('Order of Application', 'event_espresso'),
71
-        ];
72
-
73
-        $this->_sortable_columns = [
74
-            // TRUE means its already sorted
75
-            'name' => ['name' => false],
76
-        ];
77
-
78
-        $this->_hidden_columns = [];
79
-    }
80
-
81
-
82
-    protected function _get_table_filters()
83
-    {
84
-        return [];
85
-    }
86
-
87
-
88
-    protected function _add_view_counts()
89
-    {
90
-        $this->_views['all']['count'] = $this->_all_data_count;
91
-        if (
92
-            EE_Registry::instance()->CAP->current_user_can(
93
-                'ee_delete_default_price_types',
94
-                'pricing_trash_price_type'
95
-            )
96
-        ) {
97
-            $this->_views['trashed']['count'] = $this->_trashed_count;
98
-        }
99
-    }
100
-
101
-
102
-    /**
103
-     * @param EE_Price_Type $price_type
104
-     * @param string   $action
105
-     * @return string
106
-     * @throws EE_Error
107
-     * @throws ReflectionException
108
-     * @since 5.0.0.p
109
-     */
110
-    protected function getActionUrl(EE_Price_Type $price_type, string $action): string
111
-    {
112
-        if (! in_array($action, self::$actions)) {
113
-            throw new DomainException(esc_html__('Invalid Action', 'event_espresso'));
114
-        }
115
-        return EE_Admin_Page::add_query_args_and_nonce(
116
-            [
117
-                'action'   => "{$action}_price_type",
118
-                'id'       => $price_type->ID(),
119
-                'noheader' => $action !== self::ACTION_EDIT,
120
-            ],
121
-            PRICING_ADMIN_URL
122
-        );
123
-    }
124
-
125
-
126
-    public function column_cb($item): string
127
-    {
128
-        if ($item->base_type() !== 1) {
129
-            return sprintf(
130
-                '<input type="checkbox" name="checkbox[%1$s]" />',
131
-                $item->ID()
132
-            );
133
-        }
134
-        return '';
135
-    }
136
-
137
-
138
-    /**
139
-     * @param EE_Price_Type $item
140
-     * @return string
141
-     * @throws EE_Error
142
-     * @throws ReflectionException
143
-     */
144
-    public function column_id($item): string
145
-    {
146
-        $content = '<span class="ee-entity-id">' . $item->ID() . '</span>';
147
-        $content .= '<span class="show-on-mobile-view-only">' . $this->column_name($item, false) . '</span>';
148
-        return $this->columnContent('id', $content, 'end');
149
-    }
150
-
151
-
152
-    /**
153
-     * @param EE_Price_Type $price_type
154
-     * @param bool          $prep_content
155
-     * @return string
156
-     * @throws EE_Error
157
-     * @throws ReflectionException
158
-     */
159
-    public function column_name(EE_Price_Type $price_type, bool $prep_content = true): string
160
-    {
161
-
162
-        // Build row actions
163
-        $actions   = [];
164
-        $name_link = $price_type->name();
165
-        // edit price link
166
-        if (
167
-            EE_Registry::instance()->CAP->current_user_can(
168
-                'ee_edit_default_price_type',
169
-                'pricing_edit_price_type',
170
-                $price_type->ID()
171
-            )
172
-        ) {
173
-            $name_link = $this->getActionLink(
174
-                $this->getActionUrl($price_type, self::ACTION_EDIT),
175
-                stripslashes($price_type->name()),
176
-                sprintf(
177
-                    /* translators: The name of the price type */
178
-                    esc_attr__('Edit Price Type (%s)', 'event_espresso'),
179
-                    $price_type->name()
180
-                )
181
-            );
182
-
183
-            $actions['edit'] = $this->getActionLink(
184
-                $this->getActionUrl($price_type, self::ACTION_EDIT),
185
-                esc_html__('Edit', 'event_espresso'),
186
-                sprintf(
187
-                    /* translators: The name of the price type */
188
-                    esc_attr__('Edit Price Type (%s)', 'event_espresso'),
189
-                    $price_type->name()
190
-                )
191
-            );
192
-        }
193
-
194
-        if ($price_type->base_type() !== 1) {
195
-            if ($this->_view == 'all') {
196
-                // trash price link
197
-                if (
198
-                    EE_Registry::instance()->CAP->current_user_can(
199
-                        'ee_delete_default_price_type',
200
-                        'pricing_trash_price_type',
201
-                        $price_type->ID()
202
-                    )
203
-                ) {
204
-                    $actions['trash'] = $this->getActionLink(
205
-                        $this->getActionUrl($price_type, self::ACTION_TRASH),
206
-                        esc_html__('Trash', 'event_espresso'),
207
-                        sprintf(
208
-                            /* translators: The name of the price type */
209
-                            esc_attr__('Move Price Type %s to Trash', 'event_espresso'),
210
-                            $price_type->name()
211
-                        )
212
-                    );
213
-                }
214
-            } else {
215
-                // restore price link
216
-                if (
217
-                    EE_Registry::instance()->CAP->current_user_can(
218
-                        'ee_delete_default_price_type',
219
-                        'pricing_restore_price_type',
220
-                        $price_type->ID()
221
-                    )
222
-                ) {
223
-                    $actions['restore'] = $this->getActionLink(
224
-                        $this->getActionUrl($price_type, self::ACTION_RESTORE),
225
-                        esc_html__('Restore', 'event_espresso'),
226
-                        sprintf(
227
-                            /* translators: The name of the price type */
228
-                            esc_attr__('Restore Price Type (%s)', 'event_espresso'),
229
-                            $price_type->name()
230
-                        )
231
-                    );
232
-                }
233
-                // delete price link
234
-                if (
235
-                    EE_Registry::instance()->CAP->current_user_can(
236
-                        'ee_delete_default_price_type',
237
-                        'pricing_delete_price_type',
238
-                        $price_type->ID()
239
-                    )
240
-                ) {
241
-                    $actions['delete'] = $this->getActionLink(
242
-                        $this->getActionUrl($price_type, self::ACTION_DELETE),
243
-                        esc_html__('Delete Permanently', 'event_espresso'),
244
-                        sprintf(
245
-                            /* translators: The name of the price type */
246
-                            esc_attr__('Delete Price Type %s Permanently', 'event_espresso'),
247
-                            $price_type->name()
248
-                        )
249
-                    );
250
-                }
251
-            }
252
-        }
253
-
254
-        $content = $prep_content ? $name_link . $this->row_actions($actions) : $name_link;
255
-        return $prep_content ? $this->columnContent('name', $content) : $content;
256
-    }
257
-
258
-
259
-    public function column_base_type($price_type): string
260
-    {
261
-        return $this->columnContent('base_type', $price_type->base_type_name());
262
-    }
263
-
264
-
265
-    public function column_percent($price_type): string
266
-    {
267
-        $content = $price_type->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign;
268
-        return $this->columnContent('percent', $content, 'center');
269
-    }
270
-
271
-
272
-    public function column_order($price_type): string
273
-    {
274
-        return $this->columnContent('order', $price_type->order(), 'end');
275
-    }
16
+	/**
17
+	 * @var Pricing_Admin_Page
18
+	 */
19
+	protected EE_Admin_Page $_admin_page;
20
+
21
+	protected EEM_Price_Type $_PRT;
22
+
23
+
24
+	/**
25
+	 * @throws EE_Error
26
+	 * @throws ReflectionException
27
+	 */
28
+	public function __construct($admin_page)
29
+	{
30
+		parent::__construct($admin_page);
31
+		require_once(EE_MODELS . 'EEM_Price_Type.model.php');
32
+		$this->_PRT = EEM_Price_Type::instance();
33
+	}
34
+
35
+
36
+	/**
37
+	 * @throws ReflectionException
38
+	 * @throws EE_Error
39
+	 */
40
+	protected function _setup_data()
41
+	{
42
+		$trashed               = $this->_admin_page->get_view() == 'trashed';
43
+		$this->_data           = $this->_admin_page->get_price_types_overview_data($this->_per_page, false, $trashed);
44
+		$this->_all_data_count = $this->_admin_page->get_price_types_overview_data($this->_per_page, true);
45
+		$this->_trashed_count  = $this->_admin_page->get_price_types_overview_data($this->_per_page, true, true);
46
+	}
47
+
48
+
49
+	protected function _set_properties()
50
+	{
51
+		$this->_wp_list_args = [
52
+			'singular' => esc_html__('price type', 'event_espresso'),
53
+			'plural'   => esc_html__('price types', 'event_espresso'),
54
+			'ajax'     => true,
55
+			'screen'   => $this->_admin_page->get_current_screen()->id,
56
+		];
57
+
58
+		$this->_columns = [
59
+			'cb'        => '<input type="checkbox" />', // Render a checkbox instead of text
60
+			'id'        => esc_html__('ID', 'event_espresso'),
61
+			'name'      => esc_html__('Name', 'event_espresso'),
62
+			'base_type' => esc_html__('Base Type', 'event_espresso'),
63
+			'percent'   => sprintf(
64
+							   /* translators: 1: HTML new line, 2: open span tag, 3: close span tag */
65
+				esc_html__('Applied %1$s as %2$s%%%3$s or %2$s$%3$s', 'event_espresso'),
66
+				'',
67
+				'<span class="big-text">',
68
+				'</span>'
69
+			),
70
+			'order'     => esc_html__('Order of Application', 'event_espresso'),
71
+		];
72
+
73
+		$this->_sortable_columns = [
74
+			// TRUE means its already sorted
75
+			'name' => ['name' => false],
76
+		];
77
+
78
+		$this->_hidden_columns = [];
79
+	}
80
+
81
+
82
+	protected function _get_table_filters()
83
+	{
84
+		return [];
85
+	}
86
+
87
+
88
+	protected function _add_view_counts()
89
+	{
90
+		$this->_views['all']['count'] = $this->_all_data_count;
91
+		if (
92
+			EE_Registry::instance()->CAP->current_user_can(
93
+				'ee_delete_default_price_types',
94
+				'pricing_trash_price_type'
95
+			)
96
+		) {
97
+			$this->_views['trashed']['count'] = $this->_trashed_count;
98
+		}
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param EE_Price_Type $price_type
104
+	 * @param string   $action
105
+	 * @return string
106
+	 * @throws EE_Error
107
+	 * @throws ReflectionException
108
+	 * @since 5.0.0.p
109
+	 */
110
+	protected function getActionUrl(EE_Price_Type $price_type, string $action): string
111
+	{
112
+		if (! in_array($action, self::$actions)) {
113
+			throw new DomainException(esc_html__('Invalid Action', 'event_espresso'));
114
+		}
115
+		return EE_Admin_Page::add_query_args_and_nonce(
116
+			[
117
+				'action'   => "{$action}_price_type",
118
+				'id'       => $price_type->ID(),
119
+				'noheader' => $action !== self::ACTION_EDIT,
120
+			],
121
+			PRICING_ADMIN_URL
122
+		);
123
+	}
124
+
125
+
126
+	public function column_cb($item): string
127
+	{
128
+		if ($item->base_type() !== 1) {
129
+			return sprintf(
130
+				'<input type="checkbox" name="checkbox[%1$s]" />',
131
+				$item->ID()
132
+			);
133
+		}
134
+		return '';
135
+	}
136
+
137
+
138
+	/**
139
+	 * @param EE_Price_Type $item
140
+	 * @return string
141
+	 * @throws EE_Error
142
+	 * @throws ReflectionException
143
+	 */
144
+	public function column_id($item): string
145
+	{
146
+		$content = '<span class="ee-entity-id">' . $item->ID() . '</span>';
147
+		$content .= '<span class="show-on-mobile-view-only">' . $this->column_name($item, false) . '</span>';
148
+		return $this->columnContent('id', $content, 'end');
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param EE_Price_Type $price_type
154
+	 * @param bool          $prep_content
155
+	 * @return string
156
+	 * @throws EE_Error
157
+	 * @throws ReflectionException
158
+	 */
159
+	public function column_name(EE_Price_Type $price_type, bool $prep_content = true): string
160
+	{
161
+
162
+		// Build row actions
163
+		$actions   = [];
164
+		$name_link = $price_type->name();
165
+		// edit price link
166
+		if (
167
+			EE_Registry::instance()->CAP->current_user_can(
168
+				'ee_edit_default_price_type',
169
+				'pricing_edit_price_type',
170
+				$price_type->ID()
171
+			)
172
+		) {
173
+			$name_link = $this->getActionLink(
174
+				$this->getActionUrl($price_type, self::ACTION_EDIT),
175
+				stripslashes($price_type->name()),
176
+				sprintf(
177
+					/* translators: The name of the price type */
178
+					esc_attr__('Edit Price Type (%s)', 'event_espresso'),
179
+					$price_type->name()
180
+				)
181
+			);
182
+
183
+			$actions['edit'] = $this->getActionLink(
184
+				$this->getActionUrl($price_type, self::ACTION_EDIT),
185
+				esc_html__('Edit', 'event_espresso'),
186
+				sprintf(
187
+					/* translators: The name of the price type */
188
+					esc_attr__('Edit Price Type (%s)', 'event_espresso'),
189
+					$price_type->name()
190
+				)
191
+			);
192
+		}
193
+
194
+		if ($price_type->base_type() !== 1) {
195
+			if ($this->_view == 'all') {
196
+				// trash price link
197
+				if (
198
+					EE_Registry::instance()->CAP->current_user_can(
199
+						'ee_delete_default_price_type',
200
+						'pricing_trash_price_type',
201
+						$price_type->ID()
202
+					)
203
+				) {
204
+					$actions['trash'] = $this->getActionLink(
205
+						$this->getActionUrl($price_type, self::ACTION_TRASH),
206
+						esc_html__('Trash', 'event_espresso'),
207
+						sprintf(
208
+							/* translators: The name of the price type */
209
+							esc_attr__('Move Price Type %s to Trash', 'event_espresso'),
210
+							$price_type->name()
211
+						)
212
+					);
213
+				}
214
+			} else {
215
+				// restore price link
216
+				if (
217
+					EE_Registry::instance()->CAP->current_user_can(
218
+						'ee_delete_default_price_type',
219
+						'pricing_restore_price_type',
220
+						$price_type->ID()
221
+					)
222
+				) {
223
+					$actions['restore'] = $this->getActionLink(
224
+						$this->getActionUrl($price_type, self::ACTION_RESTORE),
225
+						esc_html__('Restore', 'event_espresso'),
226
+						sprintf(
227
+							/* translators: The name of the price type */
228
+							esc_attr__('Restore Price Type (%s)', 'event_espresso'),
229
+							$price_type->name()
230
+						)
231
+					);
232
+				}
233
+				// delete price link
234
+				if (
235
+					EE_Registry::instance()->CAP->current_user_can(
236
+						'ee_delete_default_price_type',
237
+						'pricing_delete_price_type',
238
+						$price_type->ID()
239
+					)
240
+				) {
241
+					$actions['delete'] = $this->getActionLink(
242
+						$this->getActionUrl($price_type, self::ACTION_DELETE),
243
+						esc_html__('Delete Permanently', 'event_espresso'),
244
+						sprintf(
245
+							/* translators: The name of the price type */
246
+							esc_attr__('Delete Price Type %s Permanently', 'event_espresso'),
247
+							$price_type->name()
248
+						)
249
+					);
250
+				}
251
+			}
252
+		}
253
+
254
+		$content = $prep_content ? $name_link . $this->row_actions($actions) : $name_link;
255
+		return $prep_content ? $this->columnContent('name', $content) : $content;
256
+	}
257
+
258
+
259
+	public function column_base_type($price_type): string
260
+	{
261
+		return $this->columnContent('base_type', $price_type->base_type_name());
262
+	}
263
+
264
+
265
+	public function column_percent($price_type): string
266
+	{
267
+		$content = $price_type->is_percent() ? '%' : EE_Registry::instance()->CFG->currency->sign;
268
+		return $this->columnContent('percent', $content, 'center');
269
+	}
270
+
271
+
272
+	public function column_order($price_type): string
273
+	{
274
+		return $this->columnContent('order', $price_type->order(), 'end');
275
+	}
276 276
 }
Please login to merge, or discard this patch.