diff --git a/h5p.info.yml b/h5p.info.yml index b8c83e4b..5e66300d 100644 --- a/h5p.info.yml +++ b/h5p.info.yml @@ -3,7 +3,7 @@ type: module description: 'Upload and view interactive HTML5 Packages to your site.' package: H5P core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^8 || ^9 || ^10 dependencies: - drupal:field - drupal:file diff --git a/h5p.install b/h5p.install index 7a45b065..12cd1828 100644 --- a/h5p.install +++ b/h5p.install @@ -250,7 +250,7 @@ function _h5p_recursive_unlink($file, $connection) { } elseif (file_exists($file)) { // Get file from file_managed if it exists - $file_uri = file_build_uri(substr($file, strpos($file, 'h5p/'), strlen($file))); + $file_uri = \Drupal::service('stream_wrapper_manager')->normalizeUri(\Drupal::config('system.file')->get('default_scheme') . ('://' . substr($file, strpos($file, 'h5p/'), strlen($file)))); $fid = $connection ->query("SELECT fid FROM {file_managed} WHERE uri = :path", array(':path' => $file_uri)) ->fetchField(); diff --git a/h5p.module b/h5p.module index 10b64490..0e15e9b0 100644 --- a/h5p.module +++ b/h5p.module @@ -50,6 +50,7 @@ function h5p_library_info_build() { 'version' => '1.0', 'license' => [ 'name' => 'MIT', + 'url' => 'https://h5p.org', 'gpl-compatible' => TRUE, ], 'js' => [ @@ -94,6 +95,7 @@ function h5p_library_info_build() { 'version' => '1.0', 'license' => [ 'name' => 'MIT', + 'url' => 'https://h5p.org', 'gpl-compatible' => TRUE, ], 'css' => [ @@ -117,6 +119,7 @@ function h5p_library_info_build() { 'version' => '1.0', 'license' => [ 'name' => 'MIT', + 'url' => 'https://h5p.org', 'gpl-compatible' => TRUE, ], 'js' => [ @@ -132,6 +135,7 @@ function h5p_library_info_build() { 'license' => [ 'name' => 'MIT', 'gpl-compatible' => TRUE, + 'url' => 'https://h5p.org', ], 'js' => [ 'vendor/h5p/h5p-core/js/h5p-version.js' => [], diff --git a/h5p.services.yml b/h5p.services.yml new file mode 100644 index 00000000..23c90199 --- /dev/null +++ b/h5p.services.yml @@ -0,0 +1,7 @@ +services: + asset.css.collection_optimizer_legacy: + class: Drupal\Core\Asset\CssCollectionOptimizer + arguments: [ '@asset.css.collection_grouper', '@asset.css.optimizer', '@asset.css.dumper', '@state', '@file_system' ] + asset.js.collection_optimizer_legacy: + class: Drupal\Core\Asset\JsCollectionOptimizer + arguments: [ '@asset.js.collection_grouper', '@asset.js.optimizer', '@asset.js.dumper', '@state', '@file_system' ] diff --git a/modules/h5peditor/h5peditor.info.yml b/modules/h5peditor/h5peditor.info.yml index fc871145..909d05c8 100644 --- a/modules/h5peditor/h5peditor.info.yml +++ b/modules/h5peditor/h5peditor.info.yml @@ -3,6 +3,6 @@ type: module description: 'Create and modify interactive HTML5 packages on your site.' package: H5P core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^8 || ^9 || ^10 dependencies: - h5p:h5p diff --git a/modules/h5peditor/h5peditor.libraries.yml b/modules/h5peditor/h5peditor.libraries.yml index 9307a954..2d6f2bfd 100644 --- a/modules/h5peditor/h5peditor.libraries.yml +++ b/modules/h5peditor/h5peditor.libraries.yml @@ -1,8 +1,9 @@ h5peditor: version: 1.0 license: - - name: MIT - - gpl-compatible: TRUE + name: MIT + url: https://h5p.org + gpl-compatible: TRUE js: scripts/application.js: {} dependencies: diff --git a/modules/h5peditor/h5peditor.module b/modules/h5peditor/h5peditor.module index 471c0498..be8edc00 100644 --- a/modules/h5peditor/h5peditor.module +++ b/modules/h5peditor/h5peditor.module @@ -12,7 +12,7 @@ function h5peditor_library_info_build() { $libraries = []; - $h5p_module_path = drupal_get_path('module', 'h5p'); + $h5p_module_path = \Drupal::service('extension.list.module')->getPath('h5p'); $libraries['h5peditor.assets'] = [ 'version' => '1.0', 'license' => [ diff --git a/modules/h5peditor/scripts/application.js b/modules/h5peditor/scripts/application.js index 1b23ae0d..113ec406 100644 --- a/modules/h5peditor/scripts/application.js +++ b/modules/h5peditor/scripts/application.js @@ -27,7 +27,7 @@ // Init editors Drupal.behaviors.H5PEditor = { attach: function (context, settings) { - $('.h5p-editor', context).once('H5PEditor').each(function () { + $(once('H5PEditor','.h5p-editor', context)).each(function () { H5PEditor.init(); // Grab data values specifc for editor instance @@ -102,7 +102,7 @@ }, detach: function (context, settings, trigger) { if (trigger === 'serialize') { - $('.h5p-editor-iframe', context).once('H5PEditor').each(function () { + $(once('H5PEditor','.h5p-editor-iframe', context)).each(function () { for (var i = 0; i < submitHandlers.length; i++) { if (submitHandlers[i].element === this) { // Trigger submit handler diff --git a/modules/h5peditor/src/H5PEditor/H5PEditorUtilities.php b/modules/h5peditor/src/H5PEditor/H5PEditorUtilities.php index 7ca966af..b2e43d8e 100644 --- a/modules/h5peditor/src/H5PEditor/H5PEditorUtilities.php +++ b/modules/h5peditor/src/H5PEditor/H5PEditorUtilities.php @@ -36,7 +36,7 @@ class H5PEditorUtilities { */ public static function getEditorSettings() { $contentValidator = H5PDrupal::getInstance('contentvalidator'); - $h5p_module_rel = base_path() . drupal_get_path('module', 'h5p'); + $h5p_module_rel = base_path() . \Drupal::service('extension.list.module')->getPath('h5p'); $settings = [ 'filesPath' => base_path() . H5PDrupal::getRelativeH5PPath(), @@ -63,7 +63,7 @@ class H5PEditorUtilities { * @return array Js and css for showing the editor */ private static function getEditorAssets() { - $h5p_module_rel = base_path() . drupal_get_path('module', 'h5p'); + $h5p_module_rel = base_path() . \Drupal::service('extension.list.module')->getPath('h5p'); $corePath = "{$h5p_module_rel}/vendor/h5p/h5p-core/"; $editorPath = "{$h5p_module_rel}/vendor/h5p/h5p-editor/"; @@ -122,7 +122,7 @@ class H5PEditorUtilities { private static function getTranslationFilePath() { $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); - $h5p_module_rel = drupal_get_path('module', 'h5p'); + $h5p_module_rel = \Drupal::service('extension.list.module')->getPath('h5p'); $languageFolder = "{$h5p_module_rel}/vendor/h5p/h5p-editor/language"; $defaultLanguage = "{$languageFolder}/en.js"; $chosenLanguage = "{$languageFolder}/{$language}.js"; diff --git a/src/Controller/H5PAJAX.php b/src/Controller/H5PAJAX.php index 5a1937bc..f6268f1d 100644 --- a/src/Controller/H5PAJAX.php +++ b/src/Controller/H5PAJAX.php @@ -112,7 +112,7 @@ class H5PAJAX extends ControllerBase { ->fields($fields) ->execute(); - $this->eventDispatcher->dispatch(FinishedEvent::FINISHED_EVENT, new FinishedEvent($fields)); + $this->eventDispatcher->dispatch(new FinishedEvent($fields), FinishedEvent::FINISHED_EVENT); return new JsonResponse(['success' => TRUE]); } diff --git a/src/Controller/H5PEmbed.php b/src/Controller/H5PEmbed.php index 5e586239..c476034d 100644 --- a/src/Controller/H5PEmbed.php +++ b/src/Controller/H5PEmbed.php @@ -26,7 +26,7 @@ class H5PEmbed extends ControllerBase { ], ]; - $h5p_module_path = drupal_get_path('module', 'h5p'); + $h5p_module_path = \Drupal::service('extension.list.module')->getPath('h5p'); // Load requested content $h5p_content = H5PContent::load($id); diff --git a/src/Entity/H5PContent.php b/src/Entity/H5PContent.php index ddc651c3..16cb0a82 100644 --- a/src/Entity/H5PContent.php +++ b/src/Entity/H5PContent.php @@ -195,7 +195,7 @@ class H5PContent extends ContentEntityBase implements ContentEntityInterface { } $h5p_path = $interface->getOption('default_path', 'h5p'); - return file_create_url("public://{$h5p_path}/exports/interactive-content-" . $this->id() . '.h5p'); + return \Drupal::service('file_url_generator')->generateAbsoluteString("public://{$h5p_path}/exports/interactive-content-" . $this->id() . '.h5p'); } /** @@ -307,7 +307,7 @@ class H5PContent extends ContentEntityBase implements ContentEntityInterface { $filtered_parameters = $this->getFilteredParameters(); $display_options = $core->getDisplayOptionsForView($this->get('disabled_features')->value, $canUpdateEntity); - $h5p_module_path = drupal_get_path('module', 'h5p'); + $h5p_module_path = \Drupal::service('extension.list.module')->getPath('h5p'); $embed_url = Url::fromUri('internal:/h5p/' . $this->id() . '/embed', ['absolute' => TRUE])->toString(TRUE)->getGeneratedUrl(); $resizer_url = Url::fromUri('internal:/' . $h5p_module_path . '/vendor/h5p/h5p-core/js/h5p-resizer.js', ['absolute' => TRUE, 'language' => FALSE])->toString(TRUE)->getGeneratedUrl(); $metadata = $this->getMetadata(); diff --git a/src/Event/FinishedEvent.php b/src/Event/FinishedEvent.php index 43eba57c..b81aa166 100644 --- a/src/Event/FinishedEvent.php +++ b/src/Event/FinishedEvent.php @@ -2,7 +2,7 @@ namespace Drupal\h5p\Event; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; /** * Wraps a node insertion demo event for event listeners. diff --git a/src/Form/H5PAdminSettingsForm.php b/src/Form/H5PAdminSettingsForm.php index a1ea1f83..f7b10381 100644 --- a/src/Form/H5PAdminSettingsForm.php +++ b/src/Form/H5PAdminSettingsForm.php @@ -27,7 +27,7 @@ class H5PAdminSettingsForm extends FormBase { $interface = H5PDrupal::getInstance(); $core = H5PDrupal::getInstance('core'); - $path = drupal_get_path('module', 'h5p'); + $path = \Drupal::service('extension.list.module')->getPath('h5p'); // Get server setup error messages $server_setup_errors = $core->checkSetupErrorMessage()->errors; diff --git a/src/Form/H5PContentUpgradeForm.php b/src/Form/H5PContentUpgradeForm.php index f8e0366c..9dd77e46 100644 --- a/src/Form/H5PContentUpgradeForm.php +++ b/src/Form/H5PContentUpgradeForm.php @@ -43,7 +43,7 @@ class H5PContentUpgradeForm extends FormBase { $contents_plural = \Drupal::translation()->formatPlural($contents, '1 content instance', '@count content instances'); $returnLink = Link::fromTextAndUrl(t('Return'), Url::fromUri('internal:/admin/content/h5p/'))->toString(); - $h5p_module_rel = base_path() . drupal_get_path('module', 'h5p'); + $h5p_module_rel = base_path() . \Drupal::service('extension.list.module')->getPath('h5p'); $settings = [ 'libraryInfo' => [ 'message' => t('You are about to upgrade %num. Please select upgrade version.', ['%num' => $contents_plural]), diff --git a/src/H5PDrupal/H5PDrupal.php b/src/H5PDrupal/H5PDrupal.php index 1f501b93..d61b212c 100644 --- a/src/H5PDrupal/H5PDrupal.php +++ b/src/H5PDrupal/H5PDrupal.php @@ -135,7 +135,7 @@ class H5PDrupal implements \H5PFrameworkInterface { 'reportingIsEnabled' => ($interface->getOption('enable_lrs_content_types', FALSE) === 1) ? TRUE : FALSE, 'libraryConfig' => $core->h5pF->getLibraryConfig(), 'pluginCacheBuster' => '?' . \Drupal::state()->get('system.css_js_query_string', '0'), - 'libraryUrl' => base_path() . drupal_get_path('module', 'h5p') . '/vendor/h5p/h5p-core/js', + 'libraryUrl' => base_path() . \Drupal::service('extension.list.module')->getPath('h5p') . '/vendor/h5p/h5p-core/js', ); if ($user->id()) { @@ -170,7 +170,7 @@ class H5PDrupal implements \H5PFrameworkInterface { // Determine cache buster $cache_buster = \Drupal::state()->get('system.css_js_query_string', '0'); - $h5p_module_path = drupal_get_path('module', 'h5p'); + $h5p_module_path = \Drupal::service('extension.list.module')->getPath('h5p'); // Add all core scripts foreach (\H5PCore::$scripts as $script) { @@ -194,11 +194,11 @@ class H5PDrupal implements \H5PFrameworkInterface { * Stylesheet assets. */ public static function aggregatedAssets($scriptAssets, $styleAssets) { - $jsOptimizer = \Drupal::service('asset.js.collection_optimizer'); - $cssOptimizer = \Drupal::service('asset.css.collection_optimizer'); + $jsOptimizer = \Drupal::service('asset.js.collection_optimizer_legacy'); + $cssOptimizer = \Drupal::service('asset.css.collection_optimizer_legacy'); $systemPerformance = \Drupal::config('system.performance'); $jsAssetConfig = ['preprocess' => $systemPerformance->get('js.preprocess')]; - $cssAssetConfig = ['preprocess' => $systemPerformance->get('css.preprocess'), 'media' => 'css']; + $cssAssetConfig = ['preprocess' => $systemPerformance->get('css.preprocess'), 'media' => 'all']; $assets = ['scripts' => [], 'styles' => []]; foreach ($scriptAssets as $jsFiles) { $assets['scripts'][] = self::createCachedPublicFiles($jsFiles, $jsOptimizer, $jsAssetConfig); @@ -228,6 +228,7 @@ class H5PDrupal implements \H5PFrameworkInterface { 'attributes' => [], 'version' => NULL, 'browsers' => [], + 'license' => FALSE, ]; foreach ($filePaths as $index => $path) { @@ -238,9 +239,9 @@ class H5PDrupal implements \H5PFrameworkInterface { 'data' => $path, ] + $assetConfig + $defaultAssetConfig; } - $cachedAsset = $optimizer->optimize($assets); + $cachedAsset = $optimizer->optimize($assets, []); - return array_map(function($publicUrl){ return file_create_url($publicUrl); }, array_column($cachedAsset, 'data')); + return array_map(function($publicUrl){ return \Drupal::service('file_url_generator')->generateAbsoluteString($publicUrl); }, array_column($cachedAsset, 'data')); } /** diff --git a/src/Plugin/Field/FieldWidget/H5PUploadWidget.php b/src/Plugin/Field/FieldWidget/H5PUploadWidget.php index d34a9d71..3549ff2e 100644 --- a/src/Plugin/Field/FieldWidget/H5PUploadWidget.php +++ b/src/Plugin/Field/FieldWidget/H5PUploadWidget.php @@ -2,6 +2,7 @@ namespace Drupal\h5p\Plugin\Field\FieldWidget; +use Drupal\Core\File\FileSystemInterface; use Drupal\h5p\Plugin\Field\H5PWidgetBase; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; @@ -66,7 +67,7 @@ class H5PUploadWidget extends H5PWidgetBase { $interface = H5PDrupal::getInstance('interface', $file_field); $h5p_path = $interface->getOption('default_path', 'h5p'); $temporary_file_path = "public://{$h5p_path}/temp/" . uniqid('h5p-'); - file_prepare_directory($temporary_file_path, FILE_CREATE_DIRECTORY); + \Drupal::service('file_system')->prepareDirectory($temporary_file_path, FileSystemInterface::CREATE_DIRECTORY); // Validate file $files = file_save_upload($file_field, $validators, $temporary_file_path); diff --git a/src/Plugin/Field/H5PWidgetBase.php b/src/Plugin/Field/H5PWidgetBase.php index dd4ecbe2..4307479a 100644 --- a/src/Plugin/Field/H5PWidgetBase.php +++ b/src/Plugin/Field/H5PWidgetBase.php @@ -2,6 +2,7 @@ namespace Drupal\h5p\Plugin\Field; +use Drupal\Core\Entity\EntityFormInterface; use Drupal\Core\Field\WidgetBase; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; @@ -140,7 +141,7 @@ abstract class H5PWidgetBase extends WidgetBase { */ private static function doNewRevision(FormStateInterface $form_state) { $form_object = $form_state->getFormObject(); - if (!($form_object instanceof \Drupal\Core\Entity\EntityFormInterface)) { + if (!($form_object instanceof EntityFormInterface)) { // Not an entity form, nothing to alter. return FALSE; } diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 24a5d8b1..e4502f9d 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -1,6 +1,8 @@ = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit1126f2a1d20d4b0a19d60d62b0198ab5::getInitializer($loader)); + call_user_func(ComposerStaticInit1126f2a1d20d4b0a19d60d62b0198ab5::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -53,7 +55,7 @@ class ComposerAutoloaderInit1126f2a1d20d4b0a19d60d62b0198ab5 $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit1126f2a1d20d4b0a19d60d62b0198ab5::$files; + $includeFiles = ComposerStaticInit1126f2a1d20d4b0a19d60d62b0198ab5::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; }