diff --git a/Command/H5pBundleCleanUpFilesCommand.php b/Command/H5pBundleCleanUpFilesCommand.php index 37ff65f..791cb82 100644 --- a/Command/H5pBundleCleanUpFilesCommand.php +++ b/Command/H5pBundleCleanUpFilesCommand.php @@ -10,7 +10,6 @@ class H5pBundleCleanUpFilesCommand extends Command { - /** * @var H5POptions $h5POptions */ diff --git a/Command/H5pBundleIncludeAssetsCommand.php b/Command/H5pBundleIncludeAssetsCommand.php index 49f2f6a..5d48803 100644 --- a/Command/H5pBundleIncludeAssetsCommand.php +++ b/Command/H5pBundleIncludeAssetsCommand.php @@ -46,9 +46,9 @@ private function includeAssets(bool $copy): void { //get dir of vendor H5P - $fromDir = $this->appKernel->getProjectDir()."/vendor/h5p/"; + $fromDir = $this->appKernel->getProjectDir() . "/vendor/h5p/"; //call service - $toDir = $this->appKernel->getProjectDir().'/public/bundles/studith5p/h5p/'; + $toDir = $this->appKernel->getProjectDir() . '/public/bundles/studith5p/h5p/'; $coreSubDir = "h5p-core/"; $coreDirs = ["fonts", "images", "js", "styles"]; @@ -57,7 +57,6 @@ private function includeAssets(bool $copy): void $editorSubDir = "h5p-editor/"; $editorDirs = ["ckeditor", "images", "language", "libs", "scripts", "styles"]; $this->createFiles($fromDir, $toDir, $editorSubDir, $editorDirs, $copy); - } private function createFiles($fromDir, $toDir, $subDir, $subDirs, $copy) @@ -69,7 +68,7 @@ private function createFiles($fromDir, $toDir, $subDir, $subDirs, $copy) $copy ? $this->recurseCopy($src, $dist) : symlink($src, $dist); - } + } } private function recurseCopy($src, $dst) diff --git a/Controller/H5PAJAXController.php b/Controller/H5PAJAXController.php index d167669..21f19c3 100644 --- a/Controller/H5PAJAXController.php +++ b/Controller/H5PAJAXController.php @@ -12,7 +12,6 @@ /** * @Route("/h5p/ajax") - * @extends AbstractController */ class H5PAJAXController extends AbstractController { @@ -62,7 +61,6 @@ public function contentTypeCacheCallback(): JsonResponse $output = ob_get_contents(); ob_end_clean(); - return $this->json(json_decode($output, true)); } diff --git a/Controller/H5PController.php b/Controller/H5PController.php index d96985f..b45e791 100644 --- a/Controller/H5PController.php +++ b/Controller/H5PController.php @@ -1,6 +1,5 @@ render( - '@StuditH5P/show.html.twig', [ + '@StuditH5P/show.html.twig', + [ 'contentId' => $content->getId(), 'isFrame' => $content->getLibrary()->isFrame(), 'h5pIntegration' => $h5pIntegration, @@ -127,11 +126,13 @@ private function handleRequest(Request $request, Content $content = null) } $h5pIntegration = $this->h5PIntegrations->getEditorIntegrationSettings($content ? $content->getId() : null); return $this->render( - '@StuditH5P/edit.html.twig', [ + '@StuditH5P/edit.html.twig', + [ 'form' => $form->createView(), 'h5pIntegration' => $h5pIntegration, 'h5pCoreTranslations' => $this->h5PIntegrations->getTranslationFilePath() - ]); + ] + ); } /** diff --git a/Controller/H5PInteractionController.php b/Controller/H5PInteractionController.php index 08bf6d8..d063513 100644 --- a/Controller/H5PInteractionController.php +++ b/Controller/H5PInteractionController.php @@ -1,9 +1,7 @@ entityManager = $entityManager; $this->resultService = $resultService; $this->serializer = $serializer; diff --git a/Core/H5PIntegration.php b/Core/H5PIntegration.php index d3dc9db..6fe55e1 100644 --- a/Core/H5PIntegration.php +++ b/Core/H5PIntegration.php @@ -1,6 +1,5 @@ core = $core; $this->options = $options; @@ -218,7 +215,9 @@ public function getFilteredParameters(Content $content): ?object 'filtered' => $content->getFilteredParameters(), 'embedType' => 'div', ]; - if (!empty($contentData['filtered'] && $contentData['filtered'] == '{}')) $contentData['filtered'] = null; + if (!empty($contentData['filtered'] && $contentData['filtered'] == '{}')) { + $contentData['filtered'] = null; + } return $this->core->filterParameters($contentData); } @@ -349,5 +348,4 @@ public function getOptions(): H5POptions { return $this->options; } - } diff --git a/Core/H5POptions.php b/Core/H5POptions.php index 3e87e13..09c7ff9 100644 --- a/Core/H5POptions.php +++ b/Core/H5POptions.php @@ -2,7 +2,6 @@ namespace Studit\H5PBundle\Core; - use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\ORM\EntityManagerInterface; @@ -135,7 +134,7 @@ public function getAbsoluteH5PPathWithSlash(): string $dir = $this->getOption('storage_dir'); $dir = $dir[0] === '/' ? $dir : '/' . $dir; - return $this->getAbsoluteWebPath() . $dir .'/'; + return $this->getAbsoluteWebPath() . $dir . '/'; } public function getAbsoluteH5PPath(): string { @@ -147,7 +146,7 @@ public function getAbsoluteH5PPath(): string public function getAbsoluteWebPath(): string { - return $this->projectRootDir .'/'. $this->getOption('web_dir'); + return $this->projectRootDir . '/' . $this->getOption('web_dir'); } public function getLibraryFileUrl($libraryFolderName, $fileName): string @@ -159,5 +158,4 @@ public function getH5PAssetPath(): string { return '/bundles/studith5p/h5p'; } - } diff --git a/Core/H5PSymfony.php b/Core/H5PSymfony.php index a28d951..963d066 100644 --- a/Core/H5PSymfony.php +++ b/Core/H5PSymfony.php @@ -1,13 +1,12 @@ options = $options; $this->editorStorage = $editorStorage; $this->tokenStorage = $tokenStorage; @@ -158,8 +155,7 @@ public function fetchExternalData( $headers = [], $files = [], $method = 'POST' - ) - { + ) { $options = []; if (!empty($data)) { $options['headers'] = ['Content-Type' => 'application/x-www-form-urlencoded']; @@ -194,7 +190,7 @@ public function fetchExternalData( // http://guzzle.readthedocs.io/en/latest/request-options.html#sink-option return true; } - if($fullData){ + if ($fullData) { // Compatibility with response of h5p.classe.php return [ 'status' => $response->getStatusCode(), @@ -510,7 +506,7 @@ public function saveLibraryData(&$libraryData, $new = true) $this->manager->flush(); $libraryData['libraryId'] = $library->getId(); if ($libraryData['runnable']) { - $h5p_first_runnable_saved = $this->getOption('first_runnable_saved', FALSE); + $h5p_first_runnable_saved = $this->getOption('first_runnable_saved', false); if (!$h5p_first_runnable_saved) { $this->setOption('first_runnable_saved', 1); } @@ -527,7 +523,7 @@ public function saveLibraryData(&$libraryData, $new = true) $library->setSemantics($libraryData['semantics']); $library->setHasIcon($libraryData['hasIcon']); $library->setMetadataSettings($libraryData['metadataSettings']); - $library->setAddTo(isset($libraryData['addTo']) ? json_encode($libraryData['addTo']) : NULL); + $library->setAddTo(isset($libraryData['addTo']) ? json_encode($libraryData['addTo']) : null); $this->manager->persist($library); $this->manager->flush(); $this->deleteLibraryDependencies($libraryData['libraryId']); @@ -574,7 +570,7 @@ private function pathsToCsv($libraryData, $key) /** * @inheritDoc */ - public function insertContent($contentData, $contentMainId = NULL) + public function insertContent($contentData, $contentMainId = null) { $content = new Content(); return $this->storeContent($contentData, $content); @@ -683,7 +679,6 @@ public function deleteLibraryUsage($contentId): void $this->manager->remove($contentLibrary); } $this->manager->flush(); - } /** @@ -894,7 +889,7 @@ public function getOption($name, $default = null) try { // return default if db/table still not created return $this->options->getOption($name, $default); - } catch (ConnectionException|TableNotFoundException $e) { + } catch (ConnectionException | TableNotFoundException $e) { return $default; } } @@ -966,7 +961,7 @@ public function getNumContent($libraryId, $skip = null) /** * @inheritDoc */ - public function isContentSlugAvailable($slug) + public function isContentSlugAvailable($slug): bool { throw new \Exception(); } @@ -1122,10 +1117,11 @@ public function replaceContentTypeCache($contentTypeCache): void } /** - * @param $tableClassName + * @param string $tableClassName * @throws Exception + * @return void */ - private function truncateTable($tableClassName) + private function truncateTable(string $tableClassName): void { $cmd = $this->manager->getClassMetadata($tableClassName); $connection = $this->manager->getConnection(); @@ -1144,11 +1140,20 @@ public function libraryHasUpgrade($library): bool return false; } + /** + * @param JsonSerializable $metadata + * @param string $lang + * @return mixed + */ public function replaceContentHubMetadataCache($metadata, $lang) { // TODO: Implement replaceContentHubMetadataCache() method. } + /** + * @param string $lang + * @return JsonSerializable + */ public function getContentHubMetadataCache($lang = 'en') { // TODO: Implement getContentHubMetadataCache() method. @@ -1162,6 +1167,11 @@ public function getContentHubMetadataChecked($lang = 'en'): ?string return $date->format(DateTimeInterface::RFC7231); } + /** + * @param $time + * @param $lang + * @return bool + */ public function setContentHubMetadataChecked($time, $lang = 'en') { // TODO: Implement setContentHubMetadataChecked() method. diff --git a/DependencyInjection/StuditH5PExtension.php b/DependencyInjection/StuditH5PExtension.php index 221f09e..91290f8 100644 --- a/DependencyInjection/StuditH5PExtension.php +++ b/DependencyInjection/StuditH5PExtension.php @@ -9,10 +9,8 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; - class StuditH5PExtension extends Extension { - /** * @inheritDoc * @throws Exception @@ -27,7 +25,7 @@ public function load(array $configs, ContainerBuilder $container) $definition->setArgument(0, $config); // stop saving the .h5p files if export/frame false - if(!$config['frame'] || !$config['export']){ + if (!$config['frame'] || !$config['export']) { $definition = $container->getDefinition("studit_h5p.core"); $definition->setArgument(4, false); } diff --git a/Editor/EditorStorage.php b/Editor/EditorStorage.php index fcb9e66..5c994f7 100644 --- a/Editor/EditorStorage.php +++ b/Editor/EditorStorage.php @@ -1,6 +1,5 @@ authorizationChecker->isGranted('ROLE_H5P_CREATE_RESTRICTED_CONTENT_TYPES'); - if ($libraries !== NULL) { + if ($libraries !== null) { return $this->getLibrariesWithDetails($libraries, $canCreateRestricted); } $libraries = []; @@ -149,8 +147,10 @@ public function getLibraries($libraries = NULL) if ($library->name === $existingLibrary->name) { // Mark old ones // This is the newest - if (($library->majorVersion === $existingLibrary->majorVersion && $library->minorVersion > $existingLibrary->minorVersion) || - ($library->majorVersion > $existingLibrary->majorVersion)) { + if ( + ($library->majorVersion === $existingLibrary->majorVersion && $library->minorVersion > $existingLibrary->minorVersion) || + ($library->majorVersion > $existingLibrary->majorVersion) + ) { $existingLibrary->isOld = true; } else { $library->isOld = true; @@ -282,4 +282,4 @@ public static function removeTemporarilySavedFiles($filePath) unlink($filePath); } } -} \ No newline at end of file +} diff --git a/Editor/LibraryStorage.php b/Editor/LibraryStorage.php index db00ce6..a5829c4 100644 --- a/Editor/LibraryStorage.php +++ b/Editor/LibraryStorage.php @@ -1,9 +1,7 @@ core->saveContent($contentData); //add id to data - if (!$content){ + if (!$content) { $contentData['id'] = $contentId; } $this->updateLibraryFiles($contentId, $contentData, $oldLibrary, $oldParameters->params ?? null); @@ -82,4 +80,4 @@ private function updateLibraryFiles($contentId, $contentData, $oldLibrary, $oldP $oldParameters ); } -} \ No newline at end of file +} diff --git a/Editor/Utilities.php b/Editor/Utilities.php index f6cb407..5242670 100644 --- a/Editor/Utilities.php +++ b/Editor/Utilities.php @@ -1,6 +1,5 @@ disabledFeatures = $disabledFeatures; } -} \ No newline at end of file +} diff --git a/Entity/ContentLibraries.php b/Entity/ContentLibraries.php index 623e84a..172eb5d 100644 --- a/Entity/ContentLibraries.php +++ b/Entity/ContentLibraries.php @@ -1,6 +1,5 @@ weight = $weight; } -} \ No newline at end of file +} diff --git a/Entity/ContentRepository.php b/Entity/ContentRepository.php index c2dc8f2..e82a8da 100644 --- a/Entity/ContentRepository.php +++ b/Entity/ContentRepository.php @@ -1,6 +1,5 @@ time = $time; } -} \ No newline at end of file +} diff --git a/Entity/ContentUserData.php b/Entity/ContentUserData.php index bb37807..1074a7e 100644 --- a/Entity/ContentUserData.php +++ b/Entity/ContentUserData.php @@ -1,6 +1,5 @@ deleteOnContentChange = $deleteOnContentChange; } - -} \ No newline at end of file +} diff --git a/Entity/Counters.php b/Entity/Counters.php index 312d7b1..87e71e8 100644 --- a/Entity/Counters.php +++ b/Entity/Counters.php @@ -1,6 +1,5 @@ num = $num; } - -} \ No newline at end of file +} diff --git a/Entity/Event.php b/Entity/Event.php index 69bdcd4..6ea0320 100644 --- a/Entity/Event.php +++ b/Entity/Event.php @@ -1,9 +1,7 @@ libraryVersion = $libraryVersion; } -} \ No newline at end of file +} diff --git a/Entity/EventRepository.php b/Entity/EventRepository.php index 69ed48c..784a088 100644 --- a/Entity/EventRepository.php +++ b/Entity/EventRepository.php @@ -1,6 +1,5 @@ setParameter('user', $userId); return $qb->getQuery()->getArrayResult(); } -} \ No newline at end of file +} diff --git a/Entity/LibrariesHubCache.php b/Entity/LibrariesHubCache.php index 05c4503..e24a334 100644 --- a/Entity/LibrariesHubCache.php +++ b/Entity/LibrariesHubCache.php @@ -1,6 +1,5 @@ owner = $owner; } -} \ No newline at end of file +} diff --git a/Entity/LibrariesLanguages.php b/Entity/LibrariesLanguages.php index ff6e6fb..d37af02 100644 --- a/Entity/LibrariesLanguages.php +++ b/Entity/LibrariesLanguages.php @@ -1,9 +1,7 @@ languageJson = $languageJson; } -} \ No newline at end of file +} diff --git a/Entity/LibrariesLanguagesRepository.php b/Entity/LibrariesLanguagesRepository.php index 38e59ff..0831fa6 100644 --- a/Entity/LibrariesLanguagesRepository.php +++ b/Entity/LibrariesLanguagesRepository.php @@ -1,9 +1,7 @@ getLocalName($name); return $this->$name; } - public function __isset($name) + public function __isset($name): bool { $name = $this->getLocalName($name); return isset($this->$name); } - public function __set($name, $value) + public function __set($name, $value): void { $name = $this->getLocalName($name); $this->$name = $value; } - private function getLocalName($name) + private function getLocalName($name): string { $name = \H5PCore::snakeToCamel([$name => 1]); - $name = array_keys($name)[0]; - return $name; + return array_keys($name)[0]; } /** * Library constructor. @@ -161,7 +165,7 @@ public function __construct() { $this->contentLibraries = new ArrayCollection(); } - public function __toString() + public function __toString(): string { return "{$this->machineName} {$this->majorVersion}.{$this->minorVersion}"; } @@ -426,5 +430,13 @@ public function setAddTo($addTo) $this->addTo = $addTo; } + public function isPatchVersionInFolderName(): bool + { + return $this->patchVersionInFolderName; + } -} \ No newline at end of file + public function setPatchVersionInFolderName(bool $patchVersionInFolderName): void + { + $this->patchVersionInFolderName = $patchVersionInFolderName; + } +} diff --git a/Entity/LibraryLibraries.php b/Entity/LibraryLibraries.php index 5347729..4542644 100644 --- a/Entity/LibraryLibraries.php +++ b/Entity/LibraryLibraries.php @@ -1,9 +1,7 @@ library = $library; } -} \ No newline at end of file +} diff --git a/Entity/LibraryLibrariesRepository.php b/Entity/LibraryLibrariesRepository.php index 5c46af9..b3be3b0 100644 --- a/Entity/LibraryLibrariesRepository.php +++ b/Entity/LibraryLibrariesRepository.php @@ -1,6 +1,5 @@ setParameter('id', $libraryId); return $qb->getQuery()->getSingleScalarResult(); } -} \ No newline at end of file +} diff --git a/Entity/LibraryRepository.php b/Entity/LibraryRepository.php index f00df46..6874370 100644 --- a/Entity/LibraryRepository.php +++ b/Entity/LibraryRepository.php @@ -1,6 +1,5 @@ setParameter('id', $libraryId); return $qb->getQuery()->getSingleScalarResult(); } - public function findLatestLibraryVersions() + + /** + * Find latest library + * @return array + * @throws \Doctrine\DBAL\Exception + */ + public function findLatestLibraryVersions(): array { $major_versions_sql = <<< EOT SELECT hl.machine_name, @@ -60,16 +65,17 @@ public function findLatestLibraryVersions() hl4.title, hl4.patch_version, hl4.restricted, - hl4.has_icon + hl4.has_icon, + hl4.patch_version_in_folder_name FROM ({$minor_versions_sql}) hl3 JOIN h5p_library hl4 ON hl3.machine_name = hl4.machine_name AND hl3.major_version = hl4.major_version AND hl3.minor_version = hl4.minor_version -GROUP BY hl4.machine_name, - hl4.major_version, - hl4.minor_version, - hl4.id, +GROUP BY hl4.machine_name, + hl4.major_version, + hl4.minor_version, + hl4.id, hl4.title, hl4.patch_version, hl4.restricted, @@ -129,7 +135,7 @@ public function findIdBy($machineName, $majorVersion, $minorVersion) return null; } } - public function isPatched($library) + public function isPatched($library): bool { $qb = $this->createQueryBuilder('l') ->select('COUNT(l)') diff --git a/Entity/Points.php b/Entity/Points.php index 97b386d..ca924cb 100644 --- a/Entity/Points.php +++ b/Entity/Points.php @@ -1,6 +1,5 @@ maxPoints = $maxPoints; } -} \ No newline at end of file +} diff --git a/Event/H5PEvents.php b/Event/H5PEvents.php index f9df125..e537e29 100644 --- a/Event/H5PEvents.php +++ b/Event/H5PEvents.php @@ -1,9 +1,7 @@ userid = $userId; @@ -87,4 +85,4 @@ protected function saveStats() $this->em->flush(); }*/ } -} \ No newline at end of file +} diff --git a/Event/LibraryFileEvent.php b/Event/LibraryFileEvent.php index a4cb529..44aeb7b 100644 --- a/Event/LibraryFileEvent.php +++ b/Event/LibraryFileEvent.php @@ -1,6 +1,5 @@ mode; } -} \ No newline at end of file +} diff --git a/Event/LibrarySemanticsEvent.php b/Event/LibrarySemanticsEvent.php index 60c80c8..73cdb52 100644 --- a/Event/LibrarySemanticsEvent.php +++ b/Event/LibrarySemanticsEvent.php @@ -1,9 +1,7 @@ minorVersion; } - -} \ No newline at end of file +} diff --git a/Form/Type/H5PType.php b/Form/Type/H5PType.php index 873fec0..e536ceb 100644 --- a/Form/Type/H5PType.php +++ b/Form/Type/H5PType.php @@ -1,6 +1,5 @@ add('parameters', HiddenType::class) ->add('save', SubmitType::class, array('label' => 'Save')); } -} \ No newline at end of file +} diff --git a/Service/H5PFileStorage.php b/Service/H5PFileStorage.php index b39b4ce..9ac9b76 100644 --- a/Service/H5PFileStorage.php +++ b/Service/H5PFileStorage.php @@ -1,6 +1,5 @@ $user->getId() ] ); - if (count($ContentUserData) > 0){ - foreach ($ContentUserData as $content){ + if (count($ContentUserData) > 0) { + foreach ($ContentUserData as $content) { $this->em->remove($content); } $this->em->flush(); diff --git a/StuditH5PBundle.php b/StuditH5PBundle.php index 03cb644..94972ec 100644 --- a/StuditH5PBundle.php +++ b/StuditH5PBundle.php @@ -1,8 +1,9 @@