diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2024-11-13 13:17:23 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2024-11-13 13:17:23 +0000 |
| commit | 59d2e4f33d291672093f49b78f3b155d49321c0d (patch) | |
| tree | 57200b97cc41de3b46fe6f1728c5b6311acc1907 /lib | |
| parent | 9fd14abeaf7a3d2996540ffa7144b81e019624a2 (diff) | |
fixed functionality issues in TIC 4387, re #4387
Merge request studip/studip!3629
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/exceptions/Exception.php | 8 | ||||
| -rw-r--r-- | lib/exceptions/resources/ResourceBookingException.php | 2 | ||||
| -rw-r--r-- | lib/exceptions/resources/ResourceBookingOverlapException.php | 2 | ||||
| -rw-r--r-- | lib/models/resources/Resource.php | 8 | ||||
| -rw-r--r-- | lib/models/resources/ResourceBooking.php | 8 |
5 files changed, 22 insertions, 6 deletions
diff --git a/lib/exceptions/Exception.php b/lib/exceptions/Exception.php index 606c03c..714998e 100644 --- a/lib/exceptions/Exception.php +++ b/lib/exceptions/Exception.php @@ -55,4 +55,12 @@ class Exception extends \Exception $this->range ); } + + /** + * @return \Range|null The range of the exception. + */ + public function getRange() : ?\Range + { + return $this->range; + } } diff --git a/lib/exceptions/resources/ResourceBookingException.php b/lib/exceptions/resources/ResourceBookingException.php index 3dcf483..a39da50 100644 --- a/lib/exceptions/resources/ResourceBookingException.php +++ b/lib/exceptions/resources/ResourceBookingException.php @@ -18,7 +18,7 @@ * This exception is thrown when a general error occurs when dealing with * ResourceBooking objects. */ -class ResourceBookingException extends InvalidArgumentException +class ResourceBookingException extends \Studip\Exception { } diff --git a/lib/exceptions/resources/ResourceBookingOverlapException.php b/lib/exceptions/resources/ResourceBookingOverlapException.php index 697cfc5..39497e7 100644 --- a/lib/exceptions/resources/ResourceBookingOverlapException.php +++ b/lib/exceptions/resources/ResourceBookingOverlapException.php @@ -18,7 +18,7 @@ * This exception is thrown when a resource booking overlaps with * other resource bookings or with a resource lock. */ -class ResourceBookingOverlapException extends InvalidArgumentException +class ResourceBookingOverlapException extends \Studip\Exception { } diff --git a/lib/models/resources/Resource.php b/lib/models/resources/Resource.php index 4dae189..661e8f4 100644 --- a/lib/models/resources/Resource.php +++ b/lib/models/resources/Resource.php @@ -872,7 +872,9 @@ class Resource extends SimpleORMap implements StudipItem $begin->format('d.m.Y H:i'), $end->format('H:i'), $e->getMessage() - ) + ), + $e->getCode(), + $e->getRange() ); } else { throw new ResourceBookingOverlapException( @@ -882,7 +884,9 @@ class Resource extends SimpleORMap implements StudipItem $begin->format('d.m.Y H:i'), $end->format('d.m.Y H:i'), $e->getMessage() - ) + ), + $e->getCode(), + $e->getRange() ); } } catch (Exception $e) { diff --git a/lib/models/resources/ResourceBooking.php b/lib/models/resources/ResourceBooking.php index 3c84cb8..49de381 100644 --- a/lib/models/resources/ResourceBooking.php +++ b/lib/models/resources/ResourceBooking.php @@ -521,6 +521,9 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen } ); } + + $course = null; + foreach ($time_intervals as $time_interval) { foreach ($existing_deleted_intervals as $deleted_interval) { if ( @@ -563,7 +566,6 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen [self::TYPE_NORMAL, self::TYPE_LOCK], [$this->id] ); - $course = null; if ( count($other_booking) >= 1 && !empty($other_booking[0]->assigned_course_date->course) @@ -606,7 +608,9 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen } if ($time_interval_overlaps) { throw new ResourceBookingOverlapException( - implode(', ', $time_interval_overlaps) + implode(', ', $time_interval_overlaps), + 0, + $course ); } |
