PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
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 6 months ago AbstractLocationApplicationService.php 1 year ago BasicLocationApplicationService.php 2 years ago CurrentLocation.php 3 months ago LiteCurrentLocation.php 6 months ago
AbstractLocationApplicationService.php
115 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 protected $container;
30
31 /**
32 * AbstractLocationApplicationService constructor.
33 *
34 * @param Container $container
35 */
36 public function __construct(Container $container)
37 {
38 $this->container = $container;
39 }
40
41 /**
42 * @return Collection
43 *
44 * @throws ContainerValueNotFoundException
45 * @throws QueryExecutionException
46 * @throws InvalidArgumentException
47 */
48 abstract public function getAllOrderedByName();
49
50 /**
51 * @return Collection
52 *
53 * @throws ContainerValueNotFoundException
54 * @throws QueryExecutionException
55 * @throws InvalidArgumentException
56 */
57 abstract public function getAllIndexedById();
58
59 /**
60 *
61 * @param Location $location
62 *
63 * @return boolean
64 *
65 * @throws ContainerValueNotFoundException
66 * @throws QueryExecutionException
67 */
68 public function delete($location)
69 {
70 /** @var AppointmentRepository $appointmentRepository */
71 $appointmentRepository = $this->container->get('domain.booking.appointment.repository');
72
73 /** @var EventRepository $eventRepository */
74 $eventRepository = $this->container->get('domain.booking.event.repository');
75
76 /** @var LocationRepository $locationRepository */
77 $locationRepository = $this->container->get('domain.locations.repository');
78
79 /** @var PeriodRepository $periodRepository */
80 $periodRepository = $this->container->get('domain.schedule.period.repository');
81
82 /** @var SpecialDayPeriodRepository $specialDayPeriodRepository */
83 $specialDayPeriodRepository = $this->container->get('domain.schedule.specialDay.period.repository');
84
85 /** @var PeriodLocationRepository $periodLocationRepository */
86 $periodLocationRepository = $this->container->get('domain.schedule.period.location.repository');
87
88 /** @var SpecialDayPeriodLocationRepository $specialDayPeriodLocationRepository */
89 $specialDayPeriodLocationRepository =
90 $this->container->get('domain.schedule.specialDay.period.location.repository');
91
92 /** @var ProviderLocationRepository $providerLocationRepository */
93 $providerLocationRepository = $this->container->get('domain.bookable.service.providerLocation.repository');
94
95 /** @var PackageServiceLocationRepository $packageServiceLocationRepository */
96 $packageServiceLocationRepository =
97 $this->container->get('domain.bookable.package.packageServiceLocation.repository');
98
99 /** @var ResourceEntitiesRepository $resourceEntitiesRepository */
100 $resourceEntitiesRepository = $this->container->get('domain.bookable.resourceEntities.repository');
101
102 return $eventRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
103 $appointmentRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
104 $periodRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
105 $specialDayPeriodRepository->updateByEntityId($location->getId()->getValue(), null, 'locationId') &&
106 $periodLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
107 $specialDayPeriodLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
108 $packageServiceLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
109 $providerLocationRepository->deleteByEntityId($location->getId()->getValue(), 'locationId') &&
110 $locationRepository->deleteViewStats($location->getId()->getValue()) &&
111 $resourceEntitiesRepository->deleteByEntityIdAndEntityType($location->getId()->getValue(), 'location') &&
112 $locationRepository->delete($location->getId()->getValue());
113 }
114 }
115