Browse Source

Issue 888 (#102)

* Separate taxonomies and fields for model, display, media_use and access

* More changes

* corrections

* Committing before pullin in upstream changes

* Rebased / smoothed over

* Re-exporting after updates

* Update islandora_core_feature.info.yml

* Updating exif field mappings to include names

* Getting rid of dependency

* Commenting back in the transaction after debugging

* Delete .NodeHasTerm.php.swp

* Delete .DeleteMediaTest.php.swp

* Coding standards

* Moving access control via taxonomy terms to islandora_demo

* Update composer.json

* Update islandora.info.yml

* Update islandora_core_feature.info.yml

* Whitespace to poke travis
pull/756/head
dannylamb 6 years ago committed by Seth Shaw
parent
commit
ff88e5dc0b
  1. 1
      README.md
  2. 1
      composer.json
  3. 6
      config/install/system.action.delete_media.yml
  4. 6
      config/install/system.action.delete_media_and_file.yml
  5. 2
      islandora.services.yml
  6. 20
      migrate/tags.csv
  7. 17
      modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.changed.yml
  8. 19
      modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.description.yml
  9. 17
      modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.name.yml
  10. 19
      modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.path.yml
  11. 4
      modules/islandora_core_feature/config/install/core.entity_view_display.media.audio.source.yml
  12. 4
      modules/islandora_core_feature/config/install/core.entity_view_display.media.file.source.yml
  13. 4
      modules/islandora_core_feature/config/install/core.entity_view_display.media.image.source.yml
  14. 4
      modules/islandora_core_feature/config/install/core.entity_view_display.media.video.source.yml
  15. 28
      modules/islandora_core_feature/config/install/field.field.media.audio.field_media_use.yml
  16. 23
      modules/islandora_core_feature/config/install/field.field.media.audio.field_tags.yml
  17. 28
      modules/islandora_core_feature/config/install/field.field.media.file.field_media_use.yml
  18. 23
      modules/islandora_core_feature/config/install/field.field.media.file.field_tags.yml
  19. 28
      modules/islandora_core_feature/config/install/field.field.media.image.field_media_use.yml
  20. 23
      modules/islandora_core_feature/config/install/field.field.media.image.field_tags.yml
  21. 28
      modules/islandora_core_feature/config/install/field.field.media.video.field_media_use.yml
  22. 23
      modules/islandora_core_feature/config/install/field.field.media.video.field_tags.yml
  23. 15
      modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_display.field_external_uri.yml
  24. 22
      modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_media_use.field_external_uri.yml
  25. 22
      modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_models.field_external_uri.yml
  26. 9
      modules/islandora_core_feature/config/install/field.storage.media.field_media_use.yml
  27. 19
      modules/islandora_core_feature/config/install/field.storage.node.field_display_hints.yml
  28. 19
      modules/islandora_core_feature/config/install/field.storage.node.field_model.yml
  29. 2
      modules/islandora_core_feature/config/install/field.storage.taxonomy_term.field_external_uri.yml
  30. 10
      modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_media_use.yml
  31. 15
      modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_models.yml
  32. 1
      modules/islandora_core_feature/config/install/media.type.audio.yml
  33. 1
      modules/islandora_core_feature/config/install/media.type.file.yml
  34. 1
      modules/islandora_core_feature/config/install/media.type.image.yml
  35. 1
      modules/islandora_core_feature/config/install/media.type.video.yml
  36. 30
      modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_media_use.yml
  37. 6
      modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_models.yml
  38. 8
      modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_display.yml
  39. 8
      modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_media_use.yml
  40. 8
      modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_models.yml
  41. 11
      modules/islandora_core_feature/config/install/taxonomy.vocabulary.tags.yml
  42. 17
      modules/islandora_core_feature/config/install/views.view.display_media.yml
  43. 14
      modules/islandora_core_feature/config/install/views.view.media_of.yml
  44. 9
      modules/islandora_core_feature/islandora_core_feature.features.yml
  45. 133
      src/IslandoraUtils.php
  46. 27
      src/MediaSource/MediaSourceService.php
  47. BIN
      src/Plugin/Condition/.NodeHasTerm.php.swp
  48. 3
      src/Plugin/Condition/NodeHasTerm.php

1
README.md

@ -231,3 +231,4 @@ an Islandora Foundation [Contributor License Agreement][5] or
[5]: http://islandora.ca/sites/default/files/islandora_cla.pdf [5]: http://islandora.ca/sites/default/files/islandora_cla.pdf
[6]: http://islandora.ca/sites/default/files/islandora_ccla.pdf [6]: http://islandora.ca/sites/default/files/islandora_ccla.pdf
[7]: http://islandora.ca/resources/contributors [7]: http://islandora.ca/resources/contributors

1
composer.json

@ -27,7 +27,6 @@
"drupal/migrate_plus" : "4.0-beta3", "drupal/migrate_plus" : "4.0-beta3",
"drupal/migrate_tools" : "4.0-beta3", "drupal/migrate_tools" : "4.0-beta3",
"drupal/migrate_source_csv" : "^2.1", "drupal/migrate_source_csv" : "^2.1",
"drupal/permissions_by_term" : "^1.51",
"drupal/token" : "^1.3", "drupal/token" : "^1.3",
"drupal/flysystem" : "^1.0", "drupal/flysystem" : "^1.0",
"islandora/chullo" : "dev-master" "islandora/chullo" : "dev-master"

6
config/install/system.action.delete_media.yml

@ -5,9 +5,9 @@ dependencies:
module: module:
- islandora - islandora
module: module:
- media - islandora
id: delete_media id: delete_media
label: 'Delete media' label: 'Delete media'
type: media type: media
plugin: delete_media plugin: delete_media
configuration: { } configuration: { }

6
config/install/system.action.delete_media_and_file.yml

@ -5,9 +5,9 @@ dependencies:
module: module:
- islandora - islandora
module: module:
- media - islandora
id: delete_media_and_file id: delete_media_and_file
label: 'Delete media and file(s)' label: 'Delete media and file(s)'
type: media type: media
plugin: delete_media_and_file plugin: delete_media_and_file
configuration: { } configuration: { }

2
islandora.services.yml

@ -47,7 +47,7 @@ services:
- { name: 'context_provider' } - { name: 'context_provider' }
islandora.media_source_service: islandora.media_source_service:
class: Drupal\islandora\MediaSource\MediaSourceService class: Drupal\islandora\MediaSource\MediaSourceService
arguments: ['@entity_type.manager', '@current_user', '@language_manager', '@entity.query', '@file_system'] arguments: ['@entity_type.manager', '@current_user', '@language_manager', '@entity.query', '@file_system', '@islandora.utils']
islandora.utils: islandora.utils:
class: Drupal\islandora\IslandoraUtils class: Drupal\islandora\IslandoraUtils
arguments: ['@entity_type.manager', '@entity_field.manager', '@entity.query', '@context.manager', '@flysystem_factory'] arguments: ['@entity_type.manager', '@entity_field.manager', '@entity.query', '@context.manager', '@flysystem_factory']

20
migrate/tags.csv

@ -1,9 +1,13 @@
vid,name,description,external_uri vid,name,description,external_uri
tags,"Preservation Master","Best quality representation of the Object appropriate for long-term preservation",http://pcdm.org/use#PreservationMasterFile islandora_media_use,"Extracted Text","A textual representation of the Object appropriate for fulltext indexing, such as a plaintext version of a document, or OCR text",http://pcdm.org/use#ExtractedText
tags,"Service File","A medium quality representation of the Object appropriate for serving to users",http://pcdm.org/use#ServiceFile islandora_media_use,"Intermediate File","High quality representation of the Object, appropriate for generating derivatives or other additional processing",http://pcdm.org/use#IntermediateFile
tags,"Thumbnail","A low resolution image representation of the Object appropriate for using as an icon",http://pcdm.org/use#ThumbnailImage islandora_media_use,"Original File","The original creation format of a file",http://pcdm.org/use#OriginalFile
tags,"Audio","A resource primarily intended to be heard. Examples include a music playback file format, an audio compact disc, and recorded speech or sounds",http://purl.org/coar/resource_type/c_18cc islandora_media_use,"Preservation Master File","Best quality representation of the Object appropriate for long-term preservation",http://pcdm.org/use#PreservationMasterFile
tags,"Binary","A generic binary file for repository items that don't fall into any other category or cannot be shown in a browser",http://purl.org/coar/resource_type/c_1843 islandora_media_use,"Service File","A medium quality representation of the Object appropriate for serving to users",http://pcdm.org/use#ServiceFile
tags,"Collection","A collection is an aggregation of items",http://purl.org/dc/dcmitype/Collection islandora_media_use,"Thumbnail Image","A low resolution image representation of the Object appropriate for using as an icon",http://pcdm.org/use#ThumbnailImage
tags,"Image","A visual representation other than text, including all types of moving image and still image",http://purl.org/coar/resource_type/c_c513 islandora_media_use,"Transcript","A textual representation of the Object appropriate for presenting to users, such as subtitles or transcript of a video. Can be used as a substitute or complement to other files for accessibility purposes",http://pcdm.org/use#Transcript
tags,"Video","A recording of visual images, usually in motion and with sound accompaniment",http://purl.org/coar/resource_type/c_12ce islandora_models,"Audio","A resource primarily intended to be heard. Examples include a music playback file format, an audio compact disc, and recorded speech or sounds",http://purl.org/coar/resource_type/c_18cc
islandora_models,"Binary","A generic binary file for repository items that don't fall into any other category or cannot be shown in a browser",http://purl.org/coar/resource_type/c_1843
islandora_models,"Collection","A collection is an aggregation of items",http://purl.org/dc/dcmitype/Collection
islandora_models,"Image","A visual representation other than text, including all types of moving image and still image",http://purl.org/coar/resource_type/c_c513
islandora_models,"Video","A recording of visual images, usually in motion and with sound accompaniment",http://purl.org/coar/resource_type/c_12ce

1 vid name description external_uri
2 tags islandora_media_use Preservation Master Extracted Text Best quality representation of the Object appropriate for long-term preservation A textual representation of the Object appropriate for fulltext indexing, such as a plaintext version of a document, or OCR text http://pcdm.org/use#PreservationMasterFile http://pcdm.org/use#ExtractedText
3 tags islandora_media_use Service File Intermediate File A medium quality representation of the Object appropriate for serving to users High quality representation of the Object, appropriate for generating derivatives or other additional processing http://pcdm.org/use#ServiceFile http://pcdm.org/use#IntermediateFile
4 tags islandora_media_use Thumbnail Original File A low resolution image representation of the Object appropriate for using as an icon The original creation format of a file http://pcdm.org/use#ThumbnailImage http://pcdm.org/use#OriginalFile
5 tags islandora_media_use Audio Preservation Master File A resource primarily intended to be heard. Examples include a music playback file format, an audio compact disc, and recorded speech or sounds Best quality representation of the Object appropriate for long-term preservation http://purl.org/coar/resource_type/c_18cc http://pcdm.org/use#PreservationMasterFile
6 tags islandora_media_use Binary Service File A generic binary file for repository items that don't fall into any other category or cannot be shown in a browser A medium quality representation of the Object appropriate for serving to users http://purl.org/coar/resource_type/c_1843 http://pcdm.org/use#ServiceFile
7 tags islandora_media_use Collection Thumbnail Image A collection is an aggregation of items A low resolution image representation of the Object appropriate for using as an icon http://purl.org/dc/dcmitype/Collection http://pcdm.org/use#ThumbnailImage
8 tags islandora_media_use Image Transcript A visual representation other than text, including all types of moving image and still image A textual representation of the Object appropriate for presenting to users, such as subtitles or transcript of a video. Can be used as a substitute or complement to other files for accessibility purposes http://purl.org/coar/resource_type/c_c513 http://pcdm.org/use#Transcript
9 tags islandora_models Video Audio A recording of visual images, usually in motion and with sound accompaniment A resource primarily intended to be heard. Examples include a music playback file format, an audio compact disc, and recorded speech or sounds http://purl.org/coar/resource_type/c_12ce http://purl.org/coar/resource_type/c_18cc
10 islandora_models Binary A generic binary file for repository items that don't fall into any other category or cannot be shown in a browser http://purl.org/coar/resource_type/c_1843
11 islandora_models Collection A collection is an aggregation of items http://purl.org/dc/dcmitype/Collection
12 islandora_models Image A visual representation other than text, including all types of moving image and still image http://purl.org/coar/resource_type/c_c513
13 islandora_models Video A recording of visual images, usually in motion and with sound accompaniment http://purl.org/coar/resource_type/c_12ce

17
modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.changed.yml

@ -1,17 +0,0 @@
langcode: en
status: true
dependencies:
config:
- taxonomy.vocabulary.tags
id: taxonomy_term.tags.changed
field_name: changed
entity_type: taxonomy_term
bundle: tags
label: Changed
description: 'The time that the term was last edited.'
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: changed

19
modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.description.yml

@ -1,19 +0,0 @@
langcode: en
status: true
dependencies:
config:
- taxonomy.vocabulary.tags
module:
- text
id: taxonomy_term.tags.description
field_name: description
entity_type: taxonomy_term
bundle: tags
label: Description
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: text_long

17
modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.name.yml

@ -1,17 +0,0 @@
langcode: en
status: true
dependencies:
config:
- taxonomy.vocabulary.tags
id: taxonomy_term.tags.name
field_name: name
entity_type: taxonomy_term
bundle: tags
label: Name
description: ''
required: true
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string

19
modules/islandora_core_feature/config/install/core.base_field_override.taxonomy_term.tags.path.yml

@ -1,19 +0,0 @@
langcode: en
status: true
dependencies:
config:
- taxonomy.vocabulary.tags
module:
- path
id: taxonomy_term.tags.path
field_name: path
entity_type: taxonomy_term
bundle: tags
label: 'URL alias'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: path

4
modules/islandora_core_feature/config/install/core.entity_view_display.media.audio.source.yml

@ -6,8 +6,8 @@ dependencies:
- field.field.media.audio.field_file_size - field.field.media.audio.field_file_size
- field.field.media.audio.field_media_audio_file - field.field.media.audio.field_media_audio_file
- field.field.media.audio.field_media_of - field.field.media.audio.field_media_of
- field.field.media.audio.field_media_use
- field.field.media.audio.field_mime_type - field.field.media.audio.field_mime_type
- field.field.media.audio.field_tags
- media.type.audio - media.type.audio
enforced: enforced:
module: module:
@ -34,8 +34,8 @@ hidden:
created: true created: true
field_file_size: true field_file_size: true
field_media_of: true field_media_of: true
field_media_use: true
field_mime_type: true field_mime_type: true
field_tags: true
langcode: true langcode: true
name: true name: true
thumbnail: true thumbnail: true

4
modules/islandora_core_feature/config/install/core.entity_view_display.media.file.source.yml

@ -6,8 +6,8 @@ dependencies:
- field.field.media.file.field_file_size - field.field.media.file.field_file_size
- field.field.media.file.field_media_file - field.field.media.file.field_media_file
- field.field.media.file.field_media_of - field.field.media.file.field_media_of
- field.field.media.file.field_media_use
- field.field.media.file.field_mime_type - field.field.media.file.field_mime_type
- field.field.media.file.field_tags
- media.type.file - media.type.file
enforced: enforced:
module: module:
@ -31,8 +31,8 @@ hidden:
created: true created: true
field_file_size: true field_file_size: true
field_media_of: true field_media_of: true
field_media_use: true
field_mime_type: true field_mime_type: true
field_tags: true
langcode: true langcode: true
name: true name: true
thumbnail: true thumbnail: true

4
modules/islandora_core_feature/config/install/core.entity_view_display.media.image.source.yml

@ -7,8 +7,8 @@ dependencies:
- field.field.media.image.field_height - field.field.media.image.field_height
- field.field.media.image.field_media_image - field.field.media.image.field_media_image
- field.field.media.image.field_media_of - field.field.media.image.field_media_of
- field.field.media.image.field_media_use
- field.field.media.image.field_mime_type - field.field.media.image.field_mime_type
- field.field.media.image.field_tags
- field.field.media.image.field_width - field.field.media.image.field_width
- media.type.image - media.type.image
enforced: enforced:
@ -35,8 +35,8 @@ hidden:
field_file_size: true field_file_size: true
field_height: true field_height: true
field_media_of: true field_media_of: true
field_media_use: true
field_mime_type: true field_mime_type: true
field_tags: true
field_width: true field_width: true
langcode: true langcode: true
name: true name: true

4
modules/islandora_core_feature/config/install/core.entity_view_display.media.video.source.yml

@ -5,9 +5,9 @@ dependencies:
- core.entity_view_mode.media.source - core.entity_view_mode.media.source
- field.field.media.video.field_file_size - field.field.media.video.field_file_size
- field.field.media.video.field_media_of - field.field.media.video.field_media_of
- field.field.media.video.field_media_use
- field.field.media.video.field_media_video_file - field.field.media.video.field_media_video_file
- field.field.media.video.field_mime_type - field.field.media.video.field_mime_type
- field.field.media.video.field_tags
- media.type.video - media.type.video
enforced: enforced:
module: module:
@ -37,8 +37,8 @@ hidden:
created: true created: true
field_file_size: true field_file_size: true
field_media_of: true field_media_of: true
field_media_use: true
field_mime_type: true field_mime_type: true
field_tags: true
langcode: true langcode: true
name: true name: true
thumbnail: true thumbnail: true

28
modules/islandora_core_feature/config/install/field.field.media.audio.field_media_use.yml

@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_media_use
- media.type.audio
- taxonomy.vocabulary.islandora_media_use
id: media.audio.field_media_use
field_name: field_media_use
entity_type: media
bundle: audio
label: 'Media Use'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
islandora_media_use: islandora_media_use
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

23
modules/islandora_core_feature/config/install/field.field.media.audio.field_tags.yml

@ -1,23 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_tags
- media.type.audio
enforced:
module:
- islandora_core_feature
id: media.audio.field_tags
field_name: field_tags
entity_type: media
bundle: audio
label: Tags
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings: { }
field_type: entity_reference

28
modules/islandora_core_feature/config/install/field.field.media.file.field_media_use.yml

@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_media_use
- media.type.file
- taxonomy.vocabulary.islandora_media_use
id: media.file.field_media_use
field_name: field_media_use
entity_type: media
bundle: file
label: 'Media Use'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
islandora_media_use: islandora_media_use
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

23
modules/islandora_core_feature/config/install/field.field.media.file.field_tags.yml

@ -1,23 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_tags
- media.type.file
enforced:
module:
- islandora_core_feature
id: media.file.field_tags
field_name: field_tags
entity_type: media
bundle: file
label: Tags
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings: { }
field_type: entity_reference

28
modules/islandora_core_feature/config/install/field.field.media.image.field_media_use.yml

@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_media_use
- media.type.image
- taxonomy.vocabulary.islandora_media_use
id: media.image.field_media_use
field_name: field_media_use
entity_type: media
bundle: image
label: 'Media Use'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
islandora_media_use: islandora_media_use
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

23
modules/islandora_core_feature/config/install/field.field.media.image.field_tags.yml

@ -1,23 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_tags
- media.type.image
enforced:
module:
- islandora_core_feature
id: media.image.field_tags
field_name: field_tags
entity_type: media
bundle: image
label: Tags
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings: { }
field_type: entity_reference

28
modules/islandora_core_feature/config/install/field.field.media.video.field_media_use.yml

@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_media_use
- media.type.video
- taxonomy.vocabulary.islandora_media_use
id: media.video.field_media_use
field_name: field_media_use
entity_type: media
bundle: video
label: 'Media Use'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
islandora_media_use: islandora_media_use
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference

23
modules/islandora_core_feature/config/install/field.field.media.video.field_tags.yml

@ -1,23 +0,0 @@
langcode: en
status: true
dependencies:
config:
- field.storage.media.field_tags
- media.type.video
enforced:
module:
- islandora_core_feature
id: media.video.field_tags
field_name: field_tags
entity_type: media
bundle: video
label: Tags
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings: { }
field_type: entity_reference

15
modules/islandora_core_feature/config/install/field.field.taxonomy_term.tags.field_external_uri.yml → modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_display.field_external_uri.yml

@ -3,23 +3,20 @@ status: true
dependencies: dependencies:
config: config:
- field.storage.taxonomy_term.field_external_uri - field.storage.taxonomy_term.field_external_uri
- taxonomy.vocabulary.tags - taxonomy.vocabulary.islandora_display
enforced:
module:
- islandora_core_feature
module: module:
- link - link
id: taxonomy_term.tags.field_external_uri id: taxonomy_term.islandora_display.field_external_uri
field_name: field_external_uri field_name: field_external_uri
entity_type: taxonomy_term entity_type: taxonomy_term
bundle: tags bundle: islandora_display
label: 'External URI' label: 'External URI'
description: '' description: ''
required: false required: false
translatable: false translatable: true
default_value: { } default_value: { }
default_value_callback: '' default_value_callback: ''
settings: settings:
link_type: 16 title: 1
title: 0 link_type: 17
field_type: link field_type: link

22
modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_media_use.field_external_uri.yml

@ -0,0 +1,22 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_external_uri
- taxonomy.vocabulary.islandora_media_use
module:
- link
id: taxonomy_term.islandora_media_use.field_external_uri
field_name: field_external_uri
entity_type: taxonomy_term
bundle: islandora_media_use
label: 'External URI'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
title: 1
link_type: 17
field_type: link

22
modules/islandora_core_feature/config/install/field.field.taxonomy_term.islandora_models.field_external_uri.yml

@ -0,0 +1,22 @@
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_external_uri
- taxonomy.vocabulary.islandora_models
module:
- link
id: taxonomy_term.islandora_models.field_external_uri
field_name: field_external_uri
entity_type: taxonomy_term
bundle: islandora_models
label: 'External URI'
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
title: 1
link_type: 17
field_type: link

9
modules/islandora_core_feature/config/install/field.storage.media.field_tags.yml → modules/islandora_core_feature/config/install/field.storage.media.field_media_use.yml

@ -1,21 +1,18 @@
langcode: en langcode: en
status: true status: true
dependencies: dependencies:
enforced:
module:
- islandora_core_feature
module: module:
- media - media
- taxonomy - taxonomy
id: media.field_tags id: media.field_media_use
field_name: field_tags field_name: field_media_use
entity_type: media entity_type: media
type: entity_reference type: entity_reference
settings: settings:
target_type: taxonomy_term target_type: taxonomy_term
module: core module: core
locked: false locked: false
cardinality: -1 cardinality: 1
translatable: true translatable: true
indexes: { } indexes: { }
persist_with_no_fields: false persist_with_no_fields: false

19
modules/islandora_core_feature/config/install/field.storage.node.field_display_hints.yml

@ -0,0 +1,19 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
id: node.field_display_hints
field_name: field_display_hints
entity_type: node
type: entity_reference
settings:
target_type: taxonomy_term
module: core
locked: false
cardinality: -1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

19
modules/islandora_core_feature/config/install/field.storage.node.field_model.yml

@ -0,0 +1,19 @@
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
id: node.field_model
field_name: field_model
entity_type: node
type: entity_reference
settings:
target_type: taxonomy_term
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false

2
modules/islandora_core_feature/config/install/field.storage.taxonomy_term.field_external_uri.yml

@ -14,7 +14,7 @@ type: link
settings: { } settings: { }
module: link module: link
locked: false locked: false
cardinality: -1 cardinality: 1
translatable: true translatable: true
indexes: { } indexes: { }
persist_with_no_fields: false persist_with_no_fields: false

10
modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.tags.yml → modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_media_use.yml

@ -2,16 +2,14 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- taxonomy.vocabulary.tags - taxonomy.vocabulary.islandora_media_use
module: module:
- content_translation - content_translation
third_party_settings: third_party_settings:
content_translation: content_translation:
enabled: false enabled: true
bundle_settings: id: taxonomy_term.islandora_media_use
untranslatable_fields_hide: '0'
id: taxonomy_term.tags
target_entity_type_id: taxonomy_term target_entity_type_id: taxonomy_term
target_bundle: tags target_bundle: islandora_media_use
default_langcode: site_default default_langcode: site_default
language_alterable: false language_alterable: false

15
modules/islandora_core_feature/config/install/language.content_settings.taxonomy_term.islandora_models.yml

@ -0,0 +1,15 @@
langcode: en
status: true
dependencies:
config:
- taxonomy.vocabulary.islandora_models
module:
- content_translation
third_party_settings:
content_translation:
enabled: true
id: taxonomy_term.islandora_models
target_entity_type_id: taxonomy_term
target_bundle: islandora_models
default_langcode: site_default
language_alterable: false

1
modules/islandora_core_feature/config/install/media.type.audio.yml

@ -13,5 +13,6 @@ new_revision: true
source_configuration: source_configuration:
source_field: field_media_audio_file source_field: field_media_audio_file
field_map: field_map:
name: name
mimetype: field_mime_type mimetype: field_mime_type
filesize: field_file_size filesize: field_file_size

1
modules/islandora_core_feature/config/install/media.type.file.yml

@ -13,5 +13,6 @@ new_revision: true
source_configuration: source_configuration:
source_field: field_media_file source_field: field_media_file
field_map: field_map:
name: name
mimetype: field_mime_type mimetype: field_mime_type
filesize: field_file_size filesize: field_file_size

1
modules/islandora_core_feature/config/install/media.type.image.yml

@ -13,6 +13,7 @@ new_revision: true
source_configuration: source_configuration:
source_field: field_media_image source_field: field_media_image
field_map: field_map:
name: name
mimetype: field_mime_type mimetype: field_mime_type
filesize: field_file_size filesize: field_file_size
width: field_width width: field_width

1
modules/islandora_core_feature/config/install/media.type.video.yml

@ -13,5 +13,6 @@ new_revision: true
source_configuration: source_configuration:
source_field: field_media_video_file source_field: field_media_video_file
field_map: field_map:
name: name
mimetype: field_mime_type mimetype: field_mime_type
filesize: field_file_size filesize: field_file_size

30
modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_media_use.yml

@ -0,0 +1,30 @@
langcode: en
status: true
dependencies:
config:
- taxonomy.vocabulary.islandora_media_use
enforced:
module:
- islandora_core_feature
module:
- taxonomy
id: taxonomy_term.islandora_media_use
targetEntityType: taxonomy_term
bundle: islandora_media_use
types:
- 'schema:Thing'
fieldMappings:
name:
properties:
- 'dc:title'
description:
properties:
- 'dc:description'
field_external_uri:
properties:
- 'owl:sameAs'
changed:
properties:
- 'schema:dateModified'
datatype_callback:
callable: 'Drupal\rdf\CommonDataConverter::dateIso8601Value'

6
modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.tags.yml → modules/islandora_core_feature/config/install/rdf.mapping.taxonomy_term.islandora_models.yml

@ -2,15 +2,15 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- taxonomy.vocabulary.tags - taxonomy.vocabulary.islandora_models
enforced: enforced:
module: module:
- islandora_core_feature - islandora_core_feature
module: module:
- taxonomy - taxonomy
id: taxonomy_term.tags id: taxonomy_term.islandora_models
targetEntityType: taxonomy_term targetEntityType: taxonomy_term
bundle: tags bundle: islandora_models
types: types:
- 'schema:Thing' - 'schema:Thing'
fieldMappings: fieldMappings:

8
modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_display.yml

@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
name: 'Islandora Display'
vid: islandora_display
description: 'Terms used to alter how a repository item is viewed. ie. basic image vs large image'
hierarchy: 0
weight: 0

8
modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_media_use.yml

@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
name: 'Islandora Media Use'
vid: islandora_media_use
description: 'Terms to define how a media object is to be used.'
hierarchy: 0
weight: 0

8
modules/islandora_core_feature/config/install/taxonomy.vocabulary.islandora_models.yml

@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
name: 'Islandora Models'
vid: islandora_models
description: 'Types of repository objects'
hierarchy: 0
weight: 0

11
modules/islandora_core_feature/config/install/taxonomy.vocabulary.tags.yml

@ -1,11 +0,0 @@
langcode: en
status: true
dependencies:
enforced:
module:
- islandora_core_feature
name: Tags
vid: tags
description: 'Use tags to group articles on similar topics into categories.'
hierarchy: 0
weight: 0

17
modules/islandora_core_feature/config/install/views.view.display_media.yml

@ -133,13 +133,13 @@ display:
footer: { } footer: { }
empty: { } empty: { }
relationships: relationships:
field_tags: field_media_use:
id: field_tags id: field_media_use
table: media__field_tags table: media__field_media_use
field: field_tags field: field_media_use
relationship: none relationship: none
group_type: group group_type: group
admin_label: 'field_tags: Taxonomy term' admin_label: 'field_media_use: Taxonomy term'
required: false required: false
plugin_id: standard plugin_id: standard
arguments: arguments:
@ -210,7 +210,7 @@ display:
id: field_external_uri_uri id: field_external_uri_uri
table: taxonomy_term__field_external_uri table: taxonomy_term__field_external_uri
field: field_external_uri_uri field: field_external_uri_uri
relationship: field_tags relationship: field_media_use
group_type: group group_type: group
admin_label: '' admin_label: ''
operator: '=' operator: '='
@ -288,7 +288,7 @@ display:
id: field_external_uri_uri id: field_external_uri_uri
table: taxonomy_term__field_external_uri table: taxonomy_term__field_external_uri
field: field_external_uri_uri field: field_external_uri_uri
relationship: field_tags relationship: field_media_use
group_type: group group_type: group
admin_label: '' admin_label: ''
operator: '=' operator: '='
@ -332,6 +332,7 @@ display:
entity_type: node entity_type: node
bundles: { } bundles: { }
title: 'Service File' title: 'Service File'
show_title: false
cache_metadata: cache_metadata:
max-age: -1 max-age: -1
contexts: contexts:
@ -364,7 +365,7 @@ display:
id: field_external_uri_uri id: field_external_uri_uri
table: taxonomy_term__field_external_uri table: taxonomy_term__field_external_uri
field: field_external_uri_uri field: field_external_uri_uri
relationship: field_tags relationship: field_media_use
group_type: group group_type: group
admin_label: '' admin_label: ''
operator: '=' operator: '='

14
modules/islandora_core_feature/config/install/views.view.media_of.yml

@ -2,8 +2,8 @@ langcode: en
status: true status: true
dependencies: dependencies:
config: config:
- field.storage.media.field_media_use
- field.storage.media.field_mime_type - field.storage.media.field_mime_type
- field.storage.media.field_tags
enforced: enforced:
module: module:
- islandora_core_feature - islandora_core_feature
@ -743,14 +743,14 @@ display:
separator: ', ' separator: ', '
field_api_classes: false field_api_classes: false
plugin_id: field plugin_id: field
field_tags: field_media_use:
id: field_tags id: field_media_use
table: media__field_tags table: media__field_media_use
field: field_tags field: field_media_use
relationship: none relationship: none
group_type: group group_type: group
admin_label: '' admin_label: ''
label: Tags label: 'Media Use'
exclude: false exclude: false
alter: alter:
alter_text: false alter_text: false
@ -935,8 +935,8 @@ display:
- url.query_args - url.query_args
- user.permissions - user.permissions
tags: tags:
- 'config:field.storage.media.field_media_use'
- 'config:field.storage.media.field_mime_type' - 'config:field.storage.media.field_mime_type'
- 'config:field.storage.media.field_tags'
- extensions - extensions
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export

9
modules/islandora_core_feature/islandora_core_feature.features.yml

@ -3,5 +3,14 @@ excluded:
- core.entity_view_display.node.article.default - core.entity_view_display.node.article.default
- core.entity_view_display.node.article.rss - core.entity_view_display.node.article.rss
- core.entity_view_display.node.article.teaser - core.entity_view_display.node.article.teaser
- core.entity_view_display.taxonomy_term.islandora_display.default
- core.entity_view_display.taxonomy_term.islandora_media_use.default
- core.entity_view_display.taxonomy_term.islandora_models.default
- field.field.node.article.field_tags - field.field.node.article.field_tags
- core.entity_form_display.taxonomy_term.islandora_display.default
- core.entity_form_display.taxonomy_term.islandora_media_use.default
- core.entity_form_display.taxonomy_term.islandora_models.default
- language.content_settings.taxonomy_term.islandora_access
- field.storage.node.field_access_terms
- taxonomy.vocabulary.islandora_access
required: true required: true

133
src/IslandoraUtils.php

@ -6,7 +6,9 @@ use Drupal\context\ContextManager;
use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityFieldManager; use Drupal\Core\Entity\EntityFieldManager;
use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Entity\Query\QueryException;
use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\flysystem\FlysystemFactory; use Drupal\flysystem\FlysystemFactory;
@ -25,7 +27,7 @@ class IslandoraUtils {
const EXTERNAL_URI_FIELD = 'field_external_uri'; const EXTERNAL_URI_FIELD = 'field_external_uri';
const MEDIA_OF_FIELD = 'field_media_of'; const MEDIA_OF_FIELD = 'field_media_of';
const TAGS_FIELD = 'field_tags'; const MEDIA_USAGE_FIELD = 'field_media_use';
/** /**
* The entity type manager. * The entity type manager.
@ -98,6 +100,10 @@ class IslandoraUtils {
* *
* @return \Drupal\node\NodeInterface * @return \Drupal\node\NodeInterface
* Parent node. * Parent node.
*
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
* Method $field->first() throws if data structure is unset and no item can
* be created.
*/ */
public function getParentNode(MediaInterface $media) { public function getParentNode(MediaInterface $media) {
if (!$media->hasField(self::MEDIA_OF_FIELD)) { if (!$media->hasField(self::MEDIA_OF_FIELD)) {
@ -124,6 +130,11 @@ class IslandoraUtils {
* *
* @return \Drupal\media\MediaInterface[] * @return \Drupal\media\MediaInterface[]
* The children Media. * The children Media.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* Calling getStorage() throws if the entity type doesn't exist.
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* Calling getStorage() throws if the storage handler couldn't be loaded.
*/ */
public function getMedia(NodeInterface $node) { public function getMedia(NodeInterface $node) {
if (!$this->entityTypeManager->getStorage('field_storage_config')->load('media.' . self::MEDIA_OF_FIELD)) { if (!$this->entityTypeManager->getStorage('field_storage_config')->load('media.' . self::MEDIA_OF_FIELD)) {
@ -146,12 +157,14 @@ class IslandoraUtils {
* *
* @return \Drupal\media\MediaInterface * @return \Drupal\media\MediaInterface
* The child Media. * The child Media.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* Calling getStorage() throws if the entity type doesn't exist.
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* Calling getStorage() throws if the storage handler couldn't be loaded.
*/ */
public function getMediaWithTerm(NodeInterface $node, TermInterface $term) { public function getMediaWithTerm(NodeInterface $node, TermInterface $term) {
$mids = $this->entityQuery->get('media') $mids = $this->getMediaReferencingNodeAndTerm($node, $term);
->condition(self::MEDIA_OF_FIELD, $node->id())
->condition(self::TAGS_FIELD, $term->id())
->execute();
if (empty($mids)) { if (empty($mids)) {
return NULL; return NULL;
} }
@ -166,13 +179,15 @@ class IslandoraUtils {
* *
* @return \Drupal\media\MediaInterface[] * @return \Drupal\media\MediaInterface[]
* Array of media. * Array of media.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* Calling getStorage() throws if the entity type doesn't exist.
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* Calling getStorage() throws if the storage handler couldn't be loaded.
*/ */
public function getReferencingMedia($fid) { public function getReferencingMedia($fid) {
// Get media fields that reference files. // Get media fields that reference files.
$fields = $this->entityQuery->get('field_storage_config') $fields = $this->getReferencingFields('media', 'file');
->condition('entity_type', 'media')
->condition('settings.target_type', 'file')
->execute();
// Process field names, stripping off 'media.' and appending 'target_id'. // Process field names, stripping off 'media.' and appending 'target_id'.
$conditions = array_map( $conditions = array_map(
@ -199,12 +214,16 @@ class IslandoraUtils {
* *
* @return \Drupal\taxonomy\TermInterface|null * @return \Drupal\taxonomy\TermInterface|null
* Term or NULL if not found. * Term or NULL if not found.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* Calling getStorage() throws if the entity type doesn't exist.
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* Calling getStorage() throws if the storage handler couldn't be loaded.
*/ */
public function getTermForUri($uri) { public function getTermForUri($uri) {
$results = $this->entityQuery->get('taxonomy_term') $results = $this->entityQuery->get('taxonomy_term')
->condition(self::EXTERNAL_URI_FIELD . '.uri', $uri) ->condition(self::EXTERNAL_URI_FIELD . '.uri', $uri)
->execute(); ->execute();
if (empty($results)) { if (empty($results)) {
return NULL; return NULL;
} }
@ -219,6 +238,10 @@ class IslandoraUtils {
* *
* @return string|null * @return string|null
* URI or NULL if not found. * URI or NULL if not found.
*
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
* Method $field->first() throws if data structure is unset and no item can
* be created.
*/ */
public function getUriForTerm(TermInterface $term) { public function getUriForTerm(TermInterface $term) {
if ($term && $term->hasField(self::EXTERNAL_URI_FIELD)) { if ($term && $term->hasField(self::EXTERNAL_URI_FIELD)) {
@ -335,6 +358,9 @@ class IslandoraUtils {
* The updated entity. * The updated entity.
* @param \Drupal\Core\Entity\ContentEntityInterface $original * @param \Drupal\Core\Entity\ContentEntityInterface $original
* The original entity. * The original entity.
*
* @return bool
* TRUE if the fields have changed.
*/ */
public function haveFieldsChanged(ContentEntityInterface $entity, ContentEntityInterface $original) { public function haveFieldsChanged(ContentEntityInterface $entity, ContentEntityInterface $original) {
@ -385,4 +411,91 @@ class IslandoraUtils {
return array_merge($schemes, $this->flysystemFactory->getSchemes()); return array_merge($schemes, $this->flysystemFactory->getSchemes());
} }
/**
* Get array of media ids that have fields that reference $node and $term.
*
* @param \Drupal\node\NodeInterface $node
* The node to reference.
* @param \Drupal\taxonomy\TermInterface $term
* The term to reference.
*
* @return array|int|null
* Array of media IDs or NULL.
*/
public function getMediaReferencingNodeAndTerm(NodeInterface $node, TermInterface $term) {
$term_fields = $this->getReferencingFields('media', 'taxonomy_term');
if (count($term_fields) <= 0) {
\Drupal::logger("No media fields reference a taxonomy term");
return NULL;
}
$node_fields = $this->getReferencingFields('media', 'node');
if (count($node_fields) <= 0) {
\Drupal::logger("No media fields reference a node.");
return NULL;
}
$remove_entity = function (&$o) {
$o = substr($o, strpos($o, '.') + 1);
};
array_walk($term_fields, $remove_entity);
array_walk($node_fields, $remove_entity);
$query = $this->entityQuery->get('media');
$taxon_condition = $this->getEntityQueryOrCondition($query, $term_fields, $term->id());
$query->condition($taxon_condition);
$node_condition = $this->getEntityQueryOrCondition($query, $node_fields, $node->id());
$query->condition($node_condition);
// Does the tags field exist?
try {
$mids = $query->execute();
}
catch (QueryException $e) {
$mids = [];
}
return $mids;
}
/**
* Get the fields on an entity of $entity_type that reference a $target_type.
*
* @param string $entity_type
* Type of entity to search for.
* @param string $target_type
* Type of entity the field references.
*
* @return array
* Array of fields.
*/
public function getReferencingFields($entity_type, $target_type) {
$fields = $this->entityQuery->get('field_storage_config')
->condition('entity_type', $entity_type)
->condition('settings.target_type', $target_type)
->execute();
if (!is_array($fields)) {
$fields = [$fields];
}
return $fields;
}
/**
* Make an OR condition for an array of fields and a value.
*
* @param \Drupal\Core\Entity\Query\QueryInterface $query
* The QueryInterface for the query.
* @param array $fields
* The array of field names.
* @param string $value
* The value to search the fields for.
*
* @return \Drupal\Core\Entity\Query\ConditionInterface
* The OR condition to add to your query.
*/
private function getEntityQueryOrCondition(QueryInterface $query, array $fields, $value) {
$condition = $query->orConditionGroup();
foreach ($fields as $field) {
$condition->condition($field, $value);
}
return $condition;
}
} }

27
src/MediaSource/MediaSourceService.php

@ -8,6 +8,7 @@ use Drupal\Core\File\FileSystem;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\islandora\IslandoraUtils;
use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
use Drupal\media\MediaTypeInterface; use Drupal\media\MediaTypeInterface;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
@ -56,6 +57,13 @@ class MediaSourceService {
*/ */
protected $fileSystem; protected $fileSystem;
/**
* Islandora Utility service.
*
* @var \Drupal\islandora\IslandoraUtils
*/
protected $islandoraUtils;
/** /**
* Constructor. * Constructor.
* *
@ -69,19 +77,23 @@ class MediaSourceService {
* Entity query. * Entity query.
* @param \Drupal\Core\File\FileSystem $file_system * @param \Drupal\Core\File\FileSystem $file_system
* File system service. * File system service.
* @param \Drupal\islandora\IslandoraUtils $islandora_utils
* Utility service.
*/ */
public function __construct( public function __construct(
EntityTypeManager $entity_type_manager, EntityTypeManager $entity_type_manager,
AccountInterface $account, AccountInterface $account,
LanguageManagerInterface $language_manager, LanguageManagerInterface $language_manager,
QueryFactory $entity_query, QueryFactory $entity_query,
FileSystem $file_system FileSystem $file_system,
IslandoraUtils $islandora_utils
) { ) {
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
$this->account = $account; $this->account = $account;
$this->languageManager = $language_manager; $this->languageManager = $language_manager;
$this->entityQuery = $entity_query; $this->entityQuery = $entity_query;
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
$this->islandoraUtils = $islandora_utils;
} }
/** /**
@ -238,10 +250,7 @@ class MediaSourceService {
$mimetype, $mimetype,
$content_location $content_location
) { ) {
$existing = $this->entityQuery->get('media') $existing = $this->islandoraUtils->getMediaReferencingNodeAndTerm($node, $taxonomy_term);
->condition('field_media_of', $node->id())
->condition('field_tags', $taxonomy_term->id())
->execute();
if (!empty($existing)) { if (!empty($existing)) {
// Just update already existing media. // Just update already existing media.
@ -299,12 +308,12 @@ class MediaSourceService {
"$source_field" => [ "$source_field" => [
'target_id' => $file->id(), 'target_id' => $file->id(),
], ],
'field_tags' => [ IslandoraUtils::MEDIA_OF_FIELD => [
'target_id' => $taxonomy_term->id(),
],
'field_media_of' => [
'target_id' => $node->id(), 'target_id' => $node->id(),
], ],
IslandoraUtils::MEDIA_USAGE_FIELD => [
'target_id' => $taxonomy_term->id(),
],
]; ];
// Set alt text. // Set alt text.

BIN
src/Plugin/Condition/.NodeHasTerm.php.swp

Binary file not shown.

3
src/Plugin/Condition/NodeHasTerm.php

@ -145,8 +145,7 @@ class NodeHasTerm extends ConditionPluginBase implements ContainerFactoryPluginI
*/ */
protected function evaluateEntity(EntityInterface $entity) { protected function evaluateEntity(EntityInterface $entity) {
foreach ($entity->referencedEntities() as $referenced_entity) { foreach ($entity->referencedEntities() as $referenced_entity) {
if ($referenced_entity->getEntityTypeId() == 'taxonomy_term' if ($referenced_entity->getEntityTypeId() == 'taxonomy_term' && $referenced_entity->hasField(IslandoraUtils::EXTERNAL_URI_FIELD)) {
&& $referenced_entity->hasField(IslandoraUtils::EXTERNAL_URI_FIELD)) {
$field = $referenced_entity->get(IslandoraUtils::EXTERNAL_URI_FIELD); $field = $referenced_entity->get(IslandoraUtils::EXTERNAL_URI_FIELD);
if (!$field->isEmpty()) { if (!$field->isEmpty()) {
$link = $field->first()->getValue(); $link = $field->first()->getValue();

Loading…
Cancel
Save