From 16fddc38e0050476cb236aa2e095192bc0e6215e Mon Sep 17 00:00:00 2001 From: KD Date: Fri, 1 Apr 2022 11:45:52 +0200 Subject: [PATCH] test --- src/Repositories/H5PRepository.php | 31 +++++++++--------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/Repositories/H5PRepository.php b/src/Repositories/H5PRepository.php index 88b5d099..c4da0050 100644 --- a/src/Repositories/H5PRepository.php +++ b/src/Repositories/H5PRepository.php @@ -11,7 +11,6 @@ use EscolaLms\HeadlessH5P\Models\H5PLibraryLanguage; use H5PFrameworkInterface; use Illuminate\Support\Facades\Log; -use TypeError; class H5PRepository implements H5PFrameworkInterface { @@ -637,29 +636,17 @@ public function deleteLibraryUsage($contentId) */ public function saveLibraryUsage($contentId, $librariesInUse) { - $contentLibraries = array_map(function ($value) use ($contentId, &$test) { - try { - return H5PContentLibrary::firstOrCreate([ - 'content_id' => $contentId, - 'library_id' => $value['library']['id'], - 'dependency_type' => $value['type'], - ], [ - 'drop_css' => boolval($value['library']['dropLibraryCss']), - 'weight' => $value['weight'], + $contentLibraries = array_map(function ($value) use ($contentId) { + return H5PContentLibrary::firstOrCreate([ + 'content_id' => $contentId, + 'library_id' => $value['library']['id'], + 'dependency_type' => $value['type'], + ], [ + 'drop_css' => boolval($value['library']['dropLibraryCss']), + 'weight' => $value['weight'], ])->toArray(); - } catch (TypeError $exception) { - dd([ - 'drop_css' => boolval($value['library']['dropLibraryCss']), - 'weight' => $value['weight'], - ], - [ - 'content_id' => $contentId, - 'library_id' => $value['library']['id'], - 'dependency_type' => $value['type'], - ] - ); - } }, $librariesInUse); + $content = H5PContent::with('library')->findOrFail($contentId); $libraryLibraries = array_map(function ($value) use ($contentId) {