# fluent-booking/1.5.24/app/Hooks/Handlers/TimeSlotServiceHandler.php

Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution, version 1.5.24. 42 lines.

- Page: https://pluginprobe.com/plugins/fluent-booking/1.5.24/code/app/Hooks/Handlers/TimeSlotServiceHandler.php
- Raw: https://pluginprobe.com/plugins/fluent-booking/1.5.24/raw/app/Hooks/Handlers/TimeSlotServiceHandler.php
- Modified: 2024-08-23T14:23:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-booking/1.5.24/code/app/Hooks/Handlers/TimeSlotServiceHandler.php#L10-L20`.

```php
<?php

namespace FluentBooking\App\Hooks\Handlers;

use FluentBooking\App\Services\TimeSlotService;

class TimeSlotServiceHandler
{
    public static function initService($calendar, $calendarEvent)
    {
        if ($calendarEvent->isProEvent()) {
            if (!defined('FLUENT_BOOKING_PRO_DIR_FILE')) {
                return new \WP_Error('pro_plugin_required', __('Pro plugin is required for this event.', 'fluent-booking'));
            }

            if ($calendarEvent->isTeamEvent()) {
                return new \FluentBookingPro\App\Services\TeamTimeSlotService($calendar, $calendarEvent);
            }

            if ($calendarEvent->isOneOffEvent()) {
                return new \FluentBookingPro\App\Modules\SingleEvent\SingleTimeSlotService($calendar, $calendarEvent);
            }
        }

        if ($calendarEvent->allowMultiBooking()) {
            return new \FluentBookingPro\App\Services\MultiTimeSlotService($calendar, $calendarEvent);
        }

        return new TimeSlotService($calendar, $calendarEvent);
    }

    public static function sendError($error, $calendarEvent, $timeZone)
    {
        wp_send_json([
            'error'           => true,
            'message'         => $error->get_error_message(),
            'available_slots' => [],
            'timezone'        => $timeZone,
            'max_lookup_date' => $calendarEvent->getMaxLookUpDate()
        ], 200);
    }
}
```
