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