PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.0.2
Booking for Appointments and Events Calendar – Amelia v2.0.2
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 / User / Provider / AddProviderCommandHandler.php
ameliabooking / src / Application / Commands / User / Provider Last commit date
AddProviderCommand.php 1 year ago AddProviderCommandHandler.php 1 year ago GetProviderCommand.php 7 years ago GetProviderCommandHandler.php 6 months ago GetProvidersCommand.php 1 year ago GetProvidersCommandHandler.php 6 months ago UpdateProviderCommand.php 1 year ago UpdateProviderCommandHandler.php 5 months ago UpdateProviderStatusCommand.php 1 year ago UpdateProviderStatusCommandHandler.php 6 months ago
AddProviderCommandHandler.php
73 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 (
49 !$command->getPermissionService()->currentUserCanWrite(Entities::EMPLOYEES) ||
50 !$command->getPermissionService()->currentUserCanWriteOthers(Entities::EMPLOYEES)
51 ) {
52 throw new AccessDeniedException('You are not allowed to add employee.');
53 }
54
55 /** @var ProviderApplicationService $providerAS */
56 $providerAS = $this->container->get('application.user.provider.service');
57
58 $this->checkMandatoryFields($command);
59
60 $providerData = $command->getFields();
61
62 $providerData = apply_filters('amelia_before_provider_added_filter', $providerData);
63
64 do_action('amelia_before_provider_added', $providerData);
65
66 $result = $providerAS->createProvider($providerData);
67
68 do_action('amelia_after_provider_added', $result ? $result->getData() : null);
69
70 return $result;
71 }
72 }
73