PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
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 / User / Provider / AddProviderCommandHandler.php
ameliabooking / src / Application / Commands / User / Provider Last commit date
AddProviderCommand.php 7 years ago AddProviderCommandHandler.php 2 years ago GetProviderCommand.php 7 years ago GetProviderCommandHandler.php 1 year ago GetProvidersCommand.php 7 years ago GetProvidersCommandHandler.php 1 year ago UpdateProviderCommand.php 7 years ago UpdateProviderCommandHandler.php 1 year ago UpdateProviderStatusCommand.php 7 years ago UpdateProviderStatusCommandHandler.php 2 years ago
AddProviderCommandHandler.php
71 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Commands\User\Provider;
4
5 use AmeliaBooking\Application\Commands\CommandHandler;
6 use AmeliaBooking\Application\Commands\CommandResult;
7 use AmeliaBooking\Application\Common\Exceptions\AccessDeniedException;
8 use AmeliaBooking\Application\Services\User\ProviderApplicationService;
9 use AmeliaBooking\Application\Services\User\UserApplicationService;
10 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
11 use AmeliaBooking\Domain\Entity\Entities;
12 use AmeliaBooking\Domain\Entity\User\AbstractUser;
13 use AmeliaBooking\Domain\Entity\User\Provider;
14 use AmeliaBooking\Domain\Factory\User\UserFactory;
15 use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id;
16 use AmeliaBooking\Domain\ValueObjects\String\Password;
17 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
18 use AmeliaBooking\Infrastructure\Repository\User\ProviderRepository;
19 use Interop\Container\Exception\ContainerException;
20 use Slim\Exception\ContainerValueNotFoundException;
21
22 /**
23 * Class AddProviderCommandHandler
24 *
25 * @package AmeliaBooking\Application\Commands\User\Provider
26 */
27 class AddProviderCommandHandler extends CommandHandler
28 {
29 public $mandatoryFields = [
30 'type',
31 'firstName',
32 'lastName',
33 'email'
34 ];
35
36 /**
37 * @param AddProviderCommand $command
38 *
39 * @return CommandResult
40 * @throws ContainerValueNotFoundException
41 * @throws AccessDeniedException
42 * @throws InvalidArgumentException
43 * @throws QueryExecutionException
44 * @throws ContainerException
45 */
46 public function handle(AddProviderCommand $command)
47 {
48 if (!$command->getPermissionService()->currentUserCanWrite(Entities::EMPLOYEES) ||
49 !$command->getPermissionService()->currentUserCanWriteOthers(Entities::EMPLOYEES)) {
50 throw new AccessDeniedException('You are not allowed to add employee.');
51 }
52
53 /** @var ProviderApplicationService $providerAS */
54 $providerAS = $this->container->get('application.user.provider.service');
55
56 $this->checkMandatoryFields($command);
57
58 $providerData = $command->getFields();
59
60 $providerData = apply_filters('amelia_before_provider_added_filter', $providerData);
61
62 do_action('amelia_before_provider_added', $providerData);
63
64 $result = $providerAS->createProvider($providerData);
65
66 do_action('amelia_after_provider_added', $result ? $result->getData() : null);
67
68 return $result;
69 }
70 }
71