Skip to content

Commit

Permalink
booking manager: migrated settings form
Browse files Browse the repository at this point in the history
  • Loading branch information
alex40724 committed Oct 4, 2024
1 parent e66baee commit 12d9a1b
Show file tree
Hide file tree
Showing 12 changed files with 696 additions and 110 deletions.
1 change: 0 additions & 1 deletion components/ILIAS/Blog/Service/class.InternalGUIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,4 @@ public function readingTime(): GUIService
$this
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use ilBookingPreferences;
use ilBookingPreferencesFactory;
use ILIAS\BookingManager\BookingProcess\WeekGridEntry;
use ILIAS\BookingManager\Settings\Settings;

/**
* Repository internal data service
Expand Down Expand Up @@ -54,4 +55,30 @@ public function weekEntry(
$html
);
}

public function settings(
int $id,
bool $public_log,
int $schedule_type,
int $overall_limit = 0,
int $reservation_period = 0,
bool $reminder_status = false,
int $reminder_day = 1,
int $pref_deadline = 0,
int $preference_nr = 0,
bool $messages = false
): Settings {
return new Settings(
$id,
$public_log,
$schedule_type,
$overall_limit,
$reservation_period,
$reminder_status,
$reminder_day,
$pref_deadline,
$preference_nr,
$messages
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,16 @@
use ILIAS\BookingManager\Objects\ObjectsManager;
use ILIAS\BookingManager\Schedule\ScheduleManager;
use ILIAS\User\UserEvent;
use ILIAS\BookingManager\Settings\SettingsManager;

/**
* @author Alexander Killing <[email protected]>
* Author: Alexander Killing <[email protected]>
*/
class InternalDomainService
{
use GlobalDICDomainServices;

/**
* @var ObjectsManager[]
*/
protected static array $object_manager = [];
/**
* @var ScheduleManager[]
*/
protected static array $schedule_manager = [];
protected static array $instances = [];
protected ?\ilLogger $book_log = null;
protected InternalRepoService $repo_service;
protected InternalDataService $data_service;
Expand All @@ -56,37 +50,23 @@ public function __construct(
$this->initDomainServices($DIC);
}

/*
public function access(int $ref_id, int $user_id) : Access\AccessManager
{
return new Access\AccessManager(
$this,
$this->access,
$ref_id,
$user_id
);
}*/

public function log(): \ilLogger
{
if (is_null($this->book_log)) {
$this->book_log = $this->logger()->book();
}
return $this->book_log;
return self::$instances["book_log"] ??= $this->logger()->book();
}

public function preferences(
\ilObjBookingPool $pool
): \ilBookingPreferencesManager {
return new \ilBookingPreferencesManager(
return self::$instances["preferences"][$pool->getId()] ??= new \ilBookingPreferencesManager(
$pool,
$this->repo_service->preferenceBasedBooking()
);
}

public function process(): BookingProcessManager
{
return new BookingProcessManager(
return self::$instances["process"] ??= new BookingProcessManager(
$this->data_service,
$this->repo_service,
$this
Expand All @@ -95,33 +75,27 @@ public function process(): BookingProcessManager

public function objects(int $pool_id): ObjectsManager
{
if (!isset(self::$object_manager[$pool_id])) {
self::$object_manager[$pool_id] = new ObjectsManager(
$this->data_service,
$this->repo_service,
$this,
$pool_id
);
}
return self::$object_manager[$pool_id];
return self::$instances["objects"][$pool_id] ??= new ObjectsManager(
$this->data_service,
$this->repo_service,
$this,
$pool_id
);
}

public function schedules(int $pool_id): ScheduleManager
{
if (!isset(self::$schedule_manager[$pool_id])) {
self::$schedule_manager[$pool_id] = new ScheduleManager(
$this->data_service,
$this->repo_service,
$this,
$pool_id
);
}
return self::$schedule_manager[$pool_id];
return self::$instances["schedules"][$pool_id] ??= new ScheduleManager(
$this->data_service,
$this->repo_service,
$this,
$pool_id
);
}

public function reservations(): Reservations\ReservationManager
{
return new Reservations\ReservationManager(
return self::$instances["reservations"] ??= new Reservations\ReservationManager(
$this->data_service,
$this->repo_service,
$this
Expand All @@ -130,7 +104,7 @@ public function reservations(): Reservations\ReservationManager

public function participants(): Participants\ParticipantsManager
{
return new Participants\ParticipantsManager(
return self::$instances["participants"] ??= new Participants\ParticipantsManager(
$this->data_service,
$this->repo_service,
$this
Expand All @@ -139,7 +113,7 @@ public function participants(): Participants\ParticipantsManager

public function objectSelection(int $pool_id): BookingProcess\ObjectSelectionManager
{
return new BookingProcess\ObjectSelectionManager(
return self::$instances["object_sel"][$pool_id] ??= new BookingProcess\ObjectSelectionManager(
$this->data_service,
$this->repo_service,
$this,
Expand All @@ -149,7 +123,15 @@ public function objectSelection(int $pool_id): BookingProcess\ObjectSelectionMan

public function userEvent(): UserEvent
{
return new UserEvent($this);
return self::$instances["user_event"] ??= new UserEvent($this);
}

public function bookingSettings(): SettingsManager
{
return self::$instances["settings"] ??= new SettingsManager(
$this->data_service,
$this->repo_service,
$this
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class InternalGUIService
{
use GlobalDICGUIServices;

protected static array $instances = [];
protected InternalDataService $data_service;
protected InternalDomainService $domain_service;

Expand Down Expand Up @@ -82,4 +82,14 @@ public function standardRequest(): StandardGUIRequest
$this->domain_service->refinery()
);
}

public function settings(): Settings\GUIService
{
return self::$instances["settings"] ??= new Settings\GUIService(
$this->data_service,
$this->domain_service,
$this
);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -18,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\BookingManager;

use ILIAS\BookingManager\Reservation\ReservationTableSessionRepository;
Expand All @@ -26,68 +26,57 @@
use ILIAS\BookingManager\BookingProcess\SelectedObjectsDBRepository;
use ILIAS\BookingManager\Schedule\SchedulesDBRepository;
use ILIAS\BookginManager\Participants\ParticipantsRepository;
use ILIAS\BookingManager\Settings\SettingsDBRepository;

/**
* Repository internal repo service
* @author Alexander Killing <[email protected]>
*/
class InternalRepoService
{
protected InternalDataService $data;
protected \ilDBInterface $db;
protected static array $instances = [];

public function __construct(InternalDataService $data, \ilDBInterface $db)
{
$this->data = $data;
$this->db = $db;
public function __construct(
protected InternalDataService $data,
protected \ilDBInterface $db
) {
}

/*
public function ...() : ...\RepoService
{
return new ...\RepoService(
$this->data,
$this->db
);
}*/

public function preferences(): \ilBookingPreferencesDBRepository
{
return new \ilBookingPreferencesDBRepository(
return self::$instances["preferences"] ??= new \ilBookingPreferencesDBRepository(
$this->data,
$this->db
);
}

public function preferenceBasedBooking(): \ilBookingPrefBasedBookGatewayRepository
{
return new \ilBookingPrefBasedBookGatewayRepository(
return self::$instances["preferenceBasedBooking"] ??= new \ilBookingPrefBasedBookGatewayRepository(
$this->db
);
}

public function reservationTable(): ReservationTableSessionRepository
{
return new ReservationTableSessionRepository();
return self::$instances["reservationTable"] ??= new ReservationTableSessionRepository();
}

public function objects(): ObjectsDBRepository
{
return new ObjectsDBRepository(
return self::$instances["objects"] ??= new ObjectsDBRepository(
$this->db
);
}

public function schedules(): SchedulesDBRepository
{
return new SchedulesDBRepository(
return self::$instances["schedules"] ??= new SchedulesDBRepository(
$this->db
);
}

public function reservation(): ReservationDBRepository
{
return new ReservationDBRepository($this->db);
return self::$instances["reservation"] ??= new ReservationDBRepository(
$this->db
);
}

/**
Expand All @@ -97,17 +86,32 @@ public function reservation(): ReservationDBRepository
public function reservationWithContextObjCache(
array $context_obj_ids
): ReservationDBRepository {
return new ReservationDBRepository($this->db, $context_obj_ids);
return new ReservationDBRepository(
$this->db,
$context_obj_ids
);
}

public function objectSelection(): SelectedObjectsDBRepository
{
return new SelectedObjectsDBRepository($this->db);
return self::$instances["objectSelection"] ??= new SelectedObjectsDBRepository(
$this->db
);
}

public function participants(): ParticipantsRepository
{
return new ParticipantsRepository($this->db);
return self::$instances["participants"] ??= new ParticipantsRepository(
$this->db
);
}

public function settings(): SettingsDBRepository
{
return self::$instances["settings"] ??= new SettingsDBRepository(
$this->db,
$this->data
);
}

}
Loading

0 comments on commit 12d9a1b

Please sign in to comment.