diff --git a/Core/H5PIntegration.php b/Core/H5PIntegration.php index 47ba62e..8e66248 100644 --- a/Core/H5PIntegration.php +++ b/Core/H5PIntegration.php @@ -110,7 +110,8 @@ public function getGenericH5PIntegrationSettings() 'l10n' => ['H5P' => $this->core->getLocalization()], 'hubIsEnabled' => $hubIsEnabled, 'siteUrl' => $this->requestStack->getMainRequest()->getUri(), - 'librairyConfig' => $this->core->h5pF->getLibraryConfig() + 'libraryConfig' => $this->core->h5pF->getLibraryConfig(), + 'reportingIsEnabled' => $this->core->h5pF->getOption('enable_lrs_content_type', false) === 1 ]; if (is_object($user)) { $settings['user'] = [ @@ -126,10 +127,10 @@ public function getGenericH5PIntegrationSettings() /** * Get a list with prepared asset links that is used when JS loads components. * - * @param null|array $keys [$keys] Optional keys, first for JS second for CSS. + * @param array|null $keys [$keys] Optional keys, first for JS second for CSS. * @return array */ - public function getCoreAssets($keys = null): array + public function getCoreAssets(?array $keys = null): array { if (empty($keys)) { $keys = ['scripts', 'styles']; @@ -141,11 +142,11 @@ public function getCoreAssets($keys = null): array ]; // Add all core scripts foreach (\H5PCore::$scripts as $script) { - $assets[$keys[0]][] = "{$this->options->getH5PAssetPath()}/h5p-core/{$script}"; + $assets[$keys[0]][] = "{$this->options->getH5PAssetPath()}/h5p-core/$script"; } // and styles foreach (\H5PCore::$styles as $style) { - $assets[$keys[1]][] = "{$this->options->getH5PAssetPath()}/h5p-core/{$style}"; + $assets[$keys[1]][] = "{$this->options->getH5PAssetPath()}/h5p-core/$style"; } return $assets; } @@ -284,7 +285,7 @@ private function getAssets($collection, $prefix, $exceptions = null): array if ($exceptions && in_array($item, $exceptions)) { continue; } - $assets[] = "{$prefix}{$item}{$cacheBuster}"; + $assets[] = "$prefix$item$cacheBuster"; } return $assets; } @@ -297,7 +298,7 @@ private function getAssets($collection, $prefix, $exceptions = null): array public function getCacheBuster(): string { $cache_buster = \H5PCore::$coreApi['majorVersion'] . '.' . \H5PCore::$coreApi['minorVersion']; - return $cache_buster ? "?={$cache_buster}" : ''; + return $cache_buster ? "?=$cache_buster" : ''; } /** diff --git a/Core/H5PSymfony.php b/Core/H5PSymfony.php index 8abbf11..6d29381 100644 --- a/Core/H5PSymfony.php +++ b/Core/H5PSymfony.php @@ -86,17 +86,16 @@ class H5PSymfony implements \H5PFrameworkInterface * @param RouterInterface $router */ public function __construct( - H5POptions $options, - EditorStorage $editorStorage, - TokenStorageInterface $tokenStorage, - EntityManagerInterface $manager, - ?Session $session, - ?RequestStack $requestStack, + H5POptions $options, + EditorStorage $editorStorage, + TokenStorageInterface $tokenStorage, + EntityManagerInterface $manager, + ?Session $session, + ?RequestStack $requestStack, AuthorizationCheckerInterface $authorizationChecker, - EventDispatcherInterface $eventDispatcher, - RouterInterface $router - ) - { + EventDispatcherInterface $eventDispatcher, + RouterInterface $router + ) { $this->options = $options; $this->editorStorage = $editorStorage; $this->tokenStorage = $tokenStorage; @@ -158,8 +157,7 @@ public function fetchExternalData( $headers = [], $files = [], $method = 'POST' - ) - { + ) { $options = []; if (!empty($data)) { $options['headers'] = ['Content-Type' => 'application/x-www-form-urlencoded']; @@ -893,7 +891,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; } } diff --git a/Core/H5PUtils.php b/Core/H5PUtils.php index 2a8b35a..4b25e80 100644 --- a/Core/H5PUtils.php +++ b/Core/H5PUtils.php @@ -21,7 +21,7 @@ public function __construct(TokenStorageInterface $tokenStorage) * Fetch the current user if not present return the anonymous user * @return string|UserInterface|null */ - public function getCurrentOrAnonymousUser() + protected function getCurrentOrAnonymousUser() { $token = $this->tokenStorage->getToken(); @@ -36,7 +36,7 @@ public function getCurrentOrAnonymousUser() * @param UserInterface|null $user * @return string|null|integer */ - public function getUserId(?UserInterface $user) + protected function getUserId(?UserInterface $user) { if ($user !== null) { if (method_exists($user, 'getId')) { diff --git a/Entity/Content.php b/Entity/Content.php index 0a61838..4929e78 100644 --- a/Entity/Content.php +++ b/Entity/Content.php @@ -90,9 +90,9 @@ public function setParameters(string $parameters) $this->parameters = $parameters; } /** - * @return string + * @return string|null */ - public function getFilteredParameters(): string + public function getFilteredParameters(): ?string { return $this->filteredParameters; } diff --git a/Service/ResultService.php b/Service/ResultService.php index 2e8950d..99207a4 100644 --- a/Service/ResultService.php +++ b/Service/ResultService.php @@ -57,15 +57,14 @@ public function handleRequestFinished(Request $request, $userId) */ public function removeData($contentId, $dataType, $user, $subContentId) { - $ContentUserData = $this->em->getRepository('Studit\H5PBundle\Entity\ContentUserData') - ->findBy( - [ - 'subContentId' => $subContentId, - 'mainContent' => $contentId, - 'dataId' => $dataType, - 'user' => $user->getId() - ] - ); + $ContentUserData = $this->em->getRepository('Studit\H5PBundle\Entity\ContentUserData')->findBy( + [ + 'subContentId' => $subContentId, + 'mainContent' => $contentId, + 'dataId' => $dataType, + 'user' => $user->getId() + ] + ); if (count($ContentUserData) > 0) { foreach ($ContentUserData as $content) { $this->em->remove($content); diff --git a/Twig/H5PExtension.php b/Twig/H5PExtension.php index 1a5ce67..88b52f9 100644 --- a/Twig/H5PExtension.php +++ b/Twig/H5PExtension.php @@ -21,14 +21,12 @@ public function __construct(H5PIntegration $h5pIntegration) $this->h5pIntegration = $h5pIntegration; } - public function getFilters() + public function getFilters(): array { - return array( - new TwigFilter('h5pCacheBuster', array($this, 'getH5PCacheBuster')), - ); + return [new TwigFilter('h5pCacheBuster', [$this, 'getH5PCacheBuster'])]; } - public function getH5PCacheBuster($script) + public function getH5PCacheBuster($script): string { return $script . $this->h5pIntegration->getCacheBuster(); } @@ -38,7 +36,7 @@ public function getH5PCacheBuster($script) * * @return string The extension name */ - public function getName() + public function getName(): string { return 'h5p_extension'; } diff --git a/composer.json b/composer.json index c52a290..56d8854 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "jorisdugue/h5p-bundle", - "version": "2.1.0", + "version": "2.2.0", "type": "symfony-bundle", "description": "H5P Bundle for Symfony 5, 6 and Symfony 7", "keywords": [ @@ -31,7 +31,7 @@ "php": ">= 7.2.5", "doctrine/orm": "^2.14.1", "guzzlehttp/guzzle": "^7.8", - "h5p/h5p-core": "dev-master#6217d57", + "h5p/h5p-core": "1.26", "h5p/h5p-editor": "^1.25", "symfony/framework-bundle": "~5.0|~6.0|~7.0", "symfony/serializer": "~5.0|~6.0|~7.0",