PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.27
Booktics – Appointment Booking Calendar for Service Businesses v1.0.27
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / calendar / calendar-registry.php

calendar-registry.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.27, at core/calendar/calendar-registry.php

55 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Calendar;
4
5 use Booktics\Contracts\Hookable_Service_Contract;
6
7 class Calendar_Registry implements Hookable_Service_Contract {
8 private static $calendars = array();
9
10 /**
11 * Register a calendar service
12 *
13 * @param string $class
14 *
15 * @return void
16 */
17 public static function register_calendar( string $class ): void {
18 if ( is_subclass_of( $class, Calendar_Interface::class ) ) {
19 $calendar_id = $class::get_id();
20 self::$calendars[ $calendar_id ] = $class;
21 }
22 }
23
24 /**
25 * Get a calendar instance by ID
26 *
27 * @param string $calendar_id
28 *
29 * @return Calendar_Interface|null
30 */
31 public static function get_calendar( string $calendar_id ): ?Calendar_Interface {
32 $class = self::$calendars[ $calendar_id ] ?? null;
33
34 return $class ? new $class() : null;
35 }
36
37 /**
38 * Get all registered calendar IDs
39 *
40 * @return array
41 */
42 public static function get_available_calendars(): array {
43 return array_keys( self::$calendars );
44 }
45
46 /**
47 * Register the service
48 *
49 * @return void
50 */
51 public function register() {
52 // Register any core calendars here if needed
53 }
54 }
55