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 |