PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.25
Booking for Appointments and Events Calendar – Amelia v1.2.25
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Application / Commands / Payment / GetPaymentCommandHandler.php
ameliabooking / src / Application / Commands / Payment Last commit date
AddPaymentCommand.php 7 years ago AddPaymentCommandHandler.php 2 years ago CalculatePaymentAmountCommand.php 4 years ago CalculatePaymentAmountCommandHandler.php 4 years ago DeletePaymentCommand.php 7 years ago DeletePaymentCommandHandler.php 2 years ago GetPaymentCommand.php 7 years ago GetPaymentCommandHandler.php 1 year ago GetPaymentsCommand.php 7 years ago GetPaymentsCommandHandler.php 1 year ago UpdatePaymentCommand.php 7 years ago UpdatePaymentCommandHandler.php 2 years ago
GetPaymentCommandHandler.php
71 lines
1 <?php
2 /**
3 * @copyright © TMS-Plugins. All rights reserved.
4 * @licence See LICENCE.md for license details.
5 */
6
7 namespace AmeliaBooking\Application\Commands\Payment;
8
9 use AmeliaBooking\Application\Commands\CommandHandler;
10 use AmeliaBooking\Application\Commands\CommandResult;
11 use AmeliaBooking\Application\Common\Exceptions\AccessDeniedException;
12 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
13 use AmeliaBooking\Domain\Entity\Payment\Payment;
14 use AmeliaBooking\Domain\Entity\Entities;
15 use AmeliaBooking\Infrastructure\Common\Exceptions\NotFoundException;
16 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
17 use AmeliaBooking\Infrastructure\Repository\Payment\PaymentRepository;
18 use Interop\Container\Exception\ContainerException;
19
20 /**
21 * Class GetPaymentCommandHandler
22 *
23 * @package AmeliaBooking\Application\Commands\Payment
24 */
25 class GetPaymentCommandHandler extends CommandHandler
26 {
27 /**
28 * @param GetPaymentCommand $command
29 *
30 * @return CommandResult
31 * @throws QueryExecutionException
32 * @throws NotFoundException
33 * @throws InvalidArgumentException
34 * @throws AccessDeniedException
35 * @throws ContainerException
36 */
37 public function handle(GetPaymentCommand $command)
38 {
39 if (!$command->getPermissionService()->currentUserCanRead(Entities::FINANCE)) {
40 throw new AccessDeniedException('You are not allowed to read payment.');
41 }
42
43 $result = new CommandResult();
44
45 $this->checkMandatoryFields($command);
46
47 /** @var PaymentRepository $paymentRepository */
48 $paymentRepository = $this->container->get('domain.payment.repository');
49
50 /** @var Payment $payment */
51 $payment = $paymentRepository->getById($command->getArg('id'));
52
53 $paymentArray = $payment->toArray();
54
55 $paymentArray = apply_filters('amelia_get_payment_filter', $paymentArray);
56
57 do_action('amelia_get_payment', $paymentArray);
58
59
60 $result->setResult(CommandResult::RESULT_SUCCESS);
61 $result->setMessage('Successfully retrieved payment.');
62 $result->setData(
63 [
64 Entities::PAYMENT => $paymentArray,
65 ]
66 );
67
68 return $result;
69 }
70 }
71