<?php
namespace Booktics\Module\Google_Calendar;

use Booktics\Module\Google_Calendar\Service\Calendar;
use Booktics\Providers\Base_Service_Provider;
use Booktics\Module\Google_Calendar\Controller\Calendar_Sync_Controller;
use Booktics\Module\Google_Calendar\Controller\Calendar_Auth_Controller;

class Google_Service_Provider extends Base_Service_Provider {
    /**
     * Store service instances
     */
    protected static $services = array();

    /**
     * Register services
     */
    public function register() {
        // Register the calendar service
        $calendar = new Calendar();
        $calendar->register();

        // Register the controller
        $controller = new Calendar_Sync_Controller();
        $controller->register();

        // Register the auth controller
        $auth_controller = new Calendar_Auth_Controller();
        $auth_controller->register();

        // Store instances statically
        self::$services = array(
            'google-calendar-service' => $calendar,
            'google-controller'       => $controller,
            'google-auth'             => $auth_controller,
        );

        // Add services to container if it exists
        if ( property_exists( $this, 'container' ) && $this->container ) {
            foreach ( self::$services as $key => $service ) {
                $this->container->addServiceProvider( $key, $service );
            }
        }
    }

    /**
     * Get a service instance
     */
    public static function get_service( $service ) {
        return self::$services[ $service ] ?? null;
    }

    /**
     * Get services - return empty array since we're handling registration manually
     */
    public function get_services() {
        return array();
    }
}
