AbstractResourceService.php
85 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\Services\Resource; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Collection\Collection; |
| 6 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 7 | use AmeliaBooking\Domain\Entity\Bookable\Service\Service; |
| 8 | use AmeliaBooking\Domain\Services\Interval\IntervalService; |
| 9 | use AmeliaBooking\Domain\Services\Schedule\ScheduleService; |
| 10 | |
| 11 | /** |
| 12 | * Class AbstractResourceService |
| 13 | * |
| 14 | * @package AmeliaBooking\Domain\Services\Resource |
| 15 | */ |
| 16 | abstract class AbstractResourceService |
| 17 | { |
| 18 | /** @var IntervalService */ |
| 19 | protected $intervalService; |
| 20 | |
| 21 | /** @var ScheduleService */ |
| 22 | protected $scheduleService; |
| 23 | |
| 24 | /** |
| 25 | * set substitute resources instead of resources that are not shred between services/locations |
| 26 | * |
| 27 | * @param Collection $resources |
| 28 | * @param array $entitiesIds |
| 29 | * @param int $serviceId |
| 30 | * |
| 31 | * @return void |
| 32 | * @throws InvalidArgumentException |
| 33 | */ |
| 34 | abstract public function setNonSharedResources($resources, $entitiesIds, $serviceId); |
| 35 | |
| 36 | /** |
| 37 | * get collection of resources for service |
| 38 | * |
| 39 | * @param Collection $resources |
| 40 | * @param int $serviceId |
| 41 | * |
| 42 | * @return Collection |
| 43 | * @throws InvalidArgumentException |
| 44 | */ |
| 45 | abstract public function getServiceResources($resources, $serviceId); |
| 46 | |
| 47 | /** |
| 48 | * get providers id values for resources |
| 49 | * |
| 50 | * @param Collection $resources |
| 51 | * |
| 52 | * @return array |
| 53 | */ |
| 54 | abstract public function getResourcesProvidersIds($resources); |
| 55 | |
| 56 | |
| 57 | /** @noinspection MoreThanThreeArgumentsInspection */ |
| 58 | /** |
| 59 | * set unavailable intervals (fake appointments) to providers in moments when resources are used up |
| 60 | * return intervals of resources with locations that are used up |
| 61 | * |
| 62 | * @param Collection $resources |
| 63 | * @param Collection $appointments |
| 64 | * @param Collection $allLocations |
| 65 | * @param Service $service |
| 66 | * @param Collection $providers |
| 67 | * @param int|null $locationId |
| 68 | * @param int|null $excludeAppointmentId |
| 69 | * @param int $personsCount |
| 70 | * |
| 71 | * @return array |
| 72 | * @throws InvalidArgumentException |
| 73 | */ |
| 74 | abstract public function manageResources( |
| 75 | $resources, |
| 76 | $appointments, |
| 77 | $allLocations, |
| 78 | $service, |
| 79 | $providers, |
| 80 | $locationId, |
| 81 | $excludeAppointmentId, |
| 82 | $personsCount |
| 83 | ); |
| 84 | } |
| 85 |