99use App \Entity \Tenant \InteractiveSlide ;
1010use App \Entity \Tenant \Slide ;
1111use App \Entity \User ;
12- use App \Exceptions \InteractiveSlideException ;
1312use App \Service \InteractiveSlideService ;
1413use App \Service \KeyVaultService ;
1514use Psr \Cache \CacheItemInterface ;
@@ -256,7 +255,7 @@ private function createEntry(string $resource, array $schedules, string $startFo
256255 */
257256 private function quickBook (Slide $ slide , InteractionSlideRequest $ interactionRequest ): array
258257 {
259- $ resource = $ this ->getValueFromInterval ('resource ' , $ interactionRequest );
258+ $ resource = ( string ) $ this ->getValueFromInterval ('resource ' , $ interactionRequest );
260259 $ durationMinutes = $ this ->getValueFromInterval ('durationMinutes ' , $ interactionRequest );
261260
262261 $ now = new \DateTime ();
@@ -446,8 +445,9 @@ private function getHeaders(string $token): array
446445
447446 private function checkPermission (InteractiveSlide $ interactive , string $ resource ): void
448447 {
448+ $ configuration = $ interactive ->getConfiguration ();
449449 // Optional limiting of available resources.
450- if (! empty ($ interactive -> getConfiguration () ['resourceEndpoint ' ])) {
450+ if (null !== $ configuration && ! empty ($ configuration ['resourceEndpoint ' ])) {
451451 $ allowedResources = $ this ->getAllowedResources ($ interactive );
452452
453453 if (!in_array ($ resource , $ allowedResources )) {
@@ -458,20 +458,31 @@ private function checkPermission(InteractiveSlide $interactive, string $resource
458458
459459 private function getAllowedResources (InteractiveSlide $ interactive ): array
460460 {
461- return $ this ->interactiveSlideCache ->get (self ::CACHE_ALLOWED_RESOURCES_PREFIX . $ interactive ->getId (), function (CacheItemInterface $ item ) use ($ interactive ) {
461+ return $ this ->interactiveSlideCache ->get (self ::CACHE_ALLOWED_RESOURCES_PREFIX . $ interactive ->getId (), function (CacheItemInterface $ item ) use ($ interactive ) {
462462 $ item ->expiresAfter (60 * 60 );
463463
464464 $ configuration = $ interactive ->getConfiguration ();
465- $ resourceEndpoint = $ this ->keyValueService ->getValue ($ configuration ['resourceEndpoint ' ]);
465+
466+ $ key = $ configuration ['resourceEndpoint ' ] ?? null ;
467+
468+ if (null === $ key ) {
469+ throw new \Exception ('resourceEndpoint not set ' );
470+ }
471+
472+ $ resourceEndpoint = $ this ->keyValueService ->getValue ($ key );
473+
474+ if (null === $ resourceEndpoint ) {
475+ throw new \Exception ('resourceEndpoint value not set ' );
476+ }
466477
467478 $ response = $ this ->client ->request ('GET ' , $ resourceEndpoint );
468479 $ content = $ response ->toArray ();
469480
470481 $ allowedResources = [];
471482
472483 foreach ($ content as $ resource ) {
473- if ($ resource [ " allowInstantBooking " ] === ' True ' ) {
474- $ allowedResources [] = $ resource [" ResourceMail " ];
484+ if (' True ' === $ resource [ ' allowInstantBooking ' ] ) {
485+ $ allowedResources [] = $ resource [' ResourceMail ' ];
475486 }
476487 }
477488
0 commit comments