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 / Stats / AddStatsCommandHandler.php
ameliabooking / src / Application / Commands / Stats Last commit date
AddStatsCommand.php 6 years ago AddStatsCommandHandler.php 2 years ago GetStatsCommand.php 7 years ago GetStatsCommandHandler.php 2 years ago
AddStatsCommandHandler.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\Stats;
8
9 use AmeliaBooking\Application\Commands\CommandHandler;
10 use AmeliaBooking\Application\Commands\CommandResult;
11 use AmeliaBooking\Application\Services\Stats\StatsService;
12
13 /**
14 * Class AddStatsCommandHandler
15 *
16 * @package AmeliaBooking\Application\Commands\Stats
17 */
18 class AddStatsCommandHandler extends CommandHandler
19 {
20
21 /**
22 * @var array
23 */
24 public $mandatoryFields = [
25 'providerId',
26 'serviceId'
27 ];
28
29 /**
30 * @param AddStatsCommand $command
31 *
32 * @return CommandResult
33 * @throws \Slim\Exception\ContainerValueNotFoundException
34 * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException
35 * @throws \Interop\Container\Exception\ContainerException
36 * @throws \AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException
37 */
38 public function handle(AddStatsCommand $command)
39 {
40 $result = new CommandResult();
41
42 /** @var StatsService $statsAS */
43 $statsAS = $this->container->get('application.stats.service');
44
45 $this->checkMandatoryFields($command);
46
47 $data = [
48 'providerId' => $command->getField('providerId'),
49 'serviceId' => $command->getField('serviceId'),
50 'locationId' => $command->getField('locationId')
51 ];
52
53 $data = apply_filters('amelia_before_stats_added_filter', $data);
54
55 do_action('amelia_before_stats_added', $data);
56
57 $statsAS->addEmployeesViewsStats($data['providerId']);
58
59 $statsAS->addServicesViewsStats($data['serviceId']);
60
61 $statsAS->addLocationsViewsStats($data['locationId']);
62
63 do_action('amelia_after_stats_added', $data);
64
65 $result->setResult(CommandResult::RESULT_SUCCESS);
66 $result->setMessage('Successfully added stats.');
67
68 return $result;
69 }
70 }
71