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 / Services / Location / AbstractLocationApplicationService.php
ameliabooking / src / Application / Services / Location Last commit date
AbstractCurrentLocation.php 2 years ago AbstractLocationApplicationService.php 2 years ago BasicLocationApplicationService.php 2 years ago CurrentLocation.php 2 years ago LiteCurrentLocation.php 2 years ago
AbstractLocationApplicationService.php
116 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Services\Location;
4
5 use AmeliaBooking\Domain\Collection\Collection;
6 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
7 use AmeliaBooking\Domain\Entity\Location\Location;
8 use AmeliaBooking\Infrastructure\Common\Container;
9 use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException;
10 use AmeliaBooking\Infrastructure\Repository\Bookable\Service\PackageServiceLocationRepository;
11 use AmeliaBooking\Infrastructure\Repository\Bookable\Service\ResourceEntitiesRepository;
12 use AmeliaBooking\Infrastructure\Repository\Booking\Appointment\AppointmentRepository;
13 use AmeliaBooking\Infrastructure\Repository\Booking\Event\EventRepository;
14 use AmeliaBooking\Infrastructure\Repository\Location\LocationRepository;
15 use AmeliaBooking\Infrastructure\Repository\Location\ProviderLocationRepository;
16 use AmeliaBooking\Infrastructure\Repository\Schedule\PeriodLocationRepository;
17 use AmeliaBooking\Infrastructure\Repository\Schedule\PeriodRepository;
18 use AmeliaBooking\Infrastructure\Repository\Schedule\SpecialDayPeriodLocationRepository;
19 use AmeliaBooking\Infrastructure\Repository\Schedule\SpecialDayPeriodRepository;
20 use Slim\Exception\ContainerValueNotFoundException;
21
22 /**
23 * Class AbstractLocationApplicationService
24 *
25 * @package AmeliaBooking\Application\Services\Location
26 */
27 abstract class AbstractLocationApplicationService
28 {
29
30 protected $container;
31
32 /**
33 * AbstractLocationApplicationService constructor.
34 *
35 * @param Container $container
36 */
37 public function __construct(Container $container)
38 {
39 $this->container = $container;
40 }
41
42 /**
43 * @return Collection
44 *
45 * @throws ContainerValueNotFoundException
46 * @throws QueryExecutionException
47 * @throws InvalidArgumentException
48 */
49 abstract public function getAllOrderedByName();
50
51 /**
52 * @return Collection
53 *
54 * @throws ContainerValueNotFoundException
55 * @throws QueryExecutionException
56 * @throws InvalidArgumentException
57 */
58 abstract public function getAllIndexedById();
59
60 /**
61 *
62 * @param Location $location
63 *
64 * @return boolean
65 *
66 * @throws ContainerValueNotFoundException
67 * @throws QueryExecutionException
68 */
69 public function delete($location)
70 {
71 /** @var AppointmentRepository $appointmentRepository */
72 $appointmentRepository = $this->container->get('domain.booking.appointment.repository');
73
74 /** @var EventRepository $eventRepository */
75 $eventRepository = $this->container->get('domain.booking.event.repository');
76
77 /** @var LocationRepository $locationRepository */
78 $locationRepository = $this->container->get('domain.locations.repository');
79
80 /** @var PeriodRepository $periodRepository */
81 $periodRepository = $this->container->get('domain.schedule.period.repository');
82
83 /** @var SpecialDayPeriodRepository $specialDayPeriodRepository */
84 $specialDayPeriodRepository = $this->container->get('domain.schedule.specialDay.period.repository');
85
86 /** @var PeriodLocationRepository $periodLocationRepository */
87 $periodLocationRepository = $this->container->get('domain.schedule.period.location.repository');
88
89 /** @var SpecialDayPeriodLocationRepository $specialDayPeriodLocationRepository */
90 $specialDayPeriodLocationRepository =
91 $this->container->get('domain.schedule.specialDay.period.location.repository');
92
93 /** @var ProviderLocationRepository $providerLocationRepository */
94 $providerLocationRepository = $this->container->get('domain.bookable.service.providerLocation.repository');
95
96 /** @var PackageServiceLocationRepository $packageServiceLocationRepository */
97 $packageServiceLocationRepository =
98 $this->container->get('domain.bookable.package.packageServiceLocation.repository');
99
100 /** @var ResourceEntitiesRepository $resourceEntitiesRepository */
101 $resourceEntitiesRepository = $this->container->get('domain.bookable.resourceEntities.repository');
102
103 return $eventRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
104 $appointmentRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
105 $periodRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
106 $specialDayPeriodRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
107 $periodLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
108 $specialDayPeriodLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
109 $packageServiceLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
110 $providerLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
111 $locationRepository->deleteViewStats($location->getId()->getValue()) &&
112 $resourceEntitiesRepository->deleteByEntityIdAndEntityType($location->getId()->getValue(), 'location') &&
113 $locationRepository->delete($location->getId()->getValue());
114 }
115 }
116