Browse Source

Drupal 10 compatibility fixes.

8.x-1.x
Alexander O'Neill 2 years ago
parent
commit
c2a7cf3cd7
  1. 2
      media_attribution.info.yml
  2. 6
      media_attribution.module
  3. 1
      src/LicenseLoader.php

2
media_attribution.info.yml

@ -1,7 +1,7 @@
name: 'Media Attribution'
type: module
description: 'Attach attribution and license info to media entities.'
core_version_requirement: ^8 || ^9
core_version_requirement: ^9.3 || ^10
package: 'media'
dependencies:
- drupal:media

6
media_attribution.module

@ -152,7 +152,7 @@ function media_attribution_preprocess_entity_embed_container(&$variables) {
$variables['children'] = [
'first' => [
'#type' => 'markup',
'#markup' => render($variables['children'])
'#markup' => \Drupal::service('renderer')->render($variables['children'])
],
$attribution_text
];
@ -162,12 +162,12 @@ function media_attribution_preprocess_entity_embed_container(&$variables) {
* Read the list of pre-defined Creative Commons media_attribution_licenses and create corresponding taxonomy terms.
*/
function media_attribution_load_default_licenses() {
$file_path = drupal_get_path('module', 'media_attribution') . '/media_attribution.default.licenses.yml';
$file_path = \Drupal::service('extension.list.module')->getPath('media_attribution') . '/media_attribution.default.licenses.yml';
$file_contents = file_get_contents($file_path);
$license_data = Yaml::decode($file_contents);
foreach ($license_data as $license_item) {
$icon_file_path = drupal_get_path('module', 'media_attribution') . "/" . $license_item['icon_file'];
$icon_file_path = \Drupal::service('extension.list.module')->getPath('media_attribution') . "/" . $license_item['icon_file'];
LicenseLoader::createLicenseTerm($license_item['title'],$license_item['short_label'], $icon_file_path, $license_item['url']);
}
}

1
src/LicenseLoader.php

@ -28,6 +28,7 @@ class LicenseLoader {
*/
public static function createOrUpdateLicenseTerm($term_title, $term_short_label, $icon_file_path, $license_url) {
$tids = array_values(\Drupal::entityQuery('taxonomy_term')
->accessCheck(TRUE)
->condition('name', $term_title)
->execute());

Loading…
Cancel
Save