Compare commits

...

77 Commits

Author SHA1 Message Date
ezoller f6a6f415d8 remove reliance on branch of crayfish-commons since PR has been merged 4 years ago
elizoller d8e7a2d9e3 code sniffer fixes...not sure how i missed these... 4 years ago
elizoller ce14534e22 remove unused use statement 4 years ago
elizoller 433d033f72 attempt to reduce shared code in the FedoraAdapterTest 4 years ago
elizoller 0ce9b3eb20 abstract awaying the shared constructor so that phpcpd is happy about less duplicated code 4 years ago
elizoller 51cd810cca code sniffer fixes 4 years ago
elizoller 6a311c8b33 reorder crayfish-commons version fix 4 years ago
ezoller 788b57047a transform 1 response from preg_match to a boolean 4 years ago
ezoller 8dc721007c update phpunit.xml? 4 years ago
ezoller 8606a96662 fixes for new classes in newer version of guzzlehttp but still needing to support old methods 4 years ago
elizoller 3850750055 testing the crayfish-commons version fix 4 years ago
elizoller 33764db9ed set fedora url to null if it isn't in the settings 4 years ago
elizoller e5c1038eeb try on the downgrade-symfony branch 4 years ago
elizoller 1ab05e79b6 more null checks 4 years ago
ezoller 24ed82c475 check for array not being null 4 years ago
ezoller 3c3262bd68 check for fedora key in flysystem 4 years ago
ezoller 4a8f23d0d6 phpcs fix 4 years ago
ezoller 985f7789c3 fix geminiclient tests 4 years ago
ezoller a5f95057f0 remove unused use statement 4 years ago
ezoller 7a5bcfadb7 fix implode ordre of parameters 4 years ago
ezoller b713f4c996 update test module info file 4 years ago
ezoller 843fda996a already the system.file config 4 years ago
ezoller 50a64ea304 putting the config in the AbstractGenerateDerivativeMediaFile class instead 4 years ago
ezoller 339391a952 fix dependency injection 4 years ago
ezoller f547b35c3e thanks @seth-shaw-unlv for this magical fix 4 years ago
ezoller b9adac5c4c sad panda 4 years ago
ezoller da26e5e5a7 i can't get the dependency injection of config correct 4 years ago
ezoller 758fc1d22f please work... 4 years ago
ezoller 4f8fef8fbe maybe it would help if i named the variables consistently 4 years ago
ezoller 90b7553fe0 missing variable name 4 years ago
ezoller 1d19ca0ae8 ugh errant semicolon 4 years ago
ezoller 5543731683 trying to fix config 4 years ago
ezoller 311196bc23 perhaps this fixes the config thing 4 years ago
ezoller 637ef08981 swap back to dev-dev crayfish-commons since PR was merged 4 years ago
ezoller 354d590615 just php 7.3 and 7.4 4 years ago
ezoller 1083d928cc use this instead of Drupal:: 4 years ago
ezoller 3643ae925e build on php7.2, 7.3, 7.4 4 years ago
ezoller d4e2c72a39 Merge branch 'd9_islandora' of https://github.com/asulibraries/islandora into d9_islandora 4 years ago
ezoller 36b959a5ec merge 8.x-1.x 4 years ago
ezoller a7b26a7329 add doc comment 4 years ago
ezoller 5d35dba26d update travis.yml for php 7.4 4 years ago
ezoller 6f51488dbb add update hook for change in migration source 4 years ago
ezoller 697efee3b9 wrong branch name 4 years ago
ezoller 2dc07e5adc point jsonld back to dev since PR has been merged 4 years ago
ezoller ec4ee15637 merge 8.x-1.x 4 years ago
ezoller 183b7075b2 fix url method 4 years ago
ezoller 02e2cb22b5 update migration keys -> ids per https://www.drupal.org/node/3060246 4 years ago
elizoller 251f28ca6a remove hook_post_action as a dependency - this does break multifile media FOR NOW 4 years ago
elizoller 6b409dc6f7 remove hook_post_action for d9 4 years ago
elizoller a4b389b323 point composer to d9 branch of jsonld 4 years ago
elizoller 073ec09767 another composer dependency adjustment 4 years ago
ezoller 01fdcfb3ef temporarily point crayfish-commons to branch with d9 dependencies 4 years ago
elizoller fcf78dcfe1 update migrate_source_csv 4 years ago
ezoller 93bcac2178 d9 requires update to flysystem module 4 years ago
Eli Zoller 5b08b765cb some of these urls are necessary as strings 4 years ago
Eli Zoller 3172f9f55f more code sniffer fixes 4 years ago
Eli Zoller ec648e6e15 replace more url() -> toUrl() and remove unused variables 4 years ago
Eli Zoller de4fcbb00c codesniffer fixes - dependencies must be prefixed with drupal: and missing variable doc comments 4 years ago
Eli Zoller 8ed7611db2 fix deprecations in tests 4 years ago
Eli Zoller eecbd83689 remove more deprecations 4 years ago
Eli Zoller 51158aa3ca fix context definitions 4 years ago
Eli Zoller 0b165a8278 replace deprecated context definition method - per https://www.drupal.org/node/2976400 4 years ago
Eli Zoller b2e71084c7 add defaultTheme per https://www.drupal.org/node/3083055 4 years ago
Eli Zoller d4a51bebe2 more deprecations with upgrade_status 3.x version and more phpcs fixes 4 years ago
Eli Zoller 1ed788a6e8 phpcs fixes and using dependency injection 4 years ago
Eli Zoller bb09637449 properly use StringTranslationTrait 4 years ago
Eli Zoller 94c1931382 fix toUrl method 4 years ago
Eli Zoller 1e3dbaeef3 phpcs fixes 4 years ago
Eli Zoller 3bb741f9d7 fix test 4 years ago
Eli Zoller 96b496a360 fix deprecations in tests 4 years ago
Eli Zoller bba922f637 use dependency injection for messenger and fix other deprecated functions for d9 4 years ago
Eli Zoller 56ae235f51 replace deprecated functions 4 years ago
Eli Zoller 2b726b9446 remove deprecated entity query 4 years ago
elizoller 406a75d4a9 stream_for updates for d9 4 years ago
elizoller 3b23a864fd update info files 4 years ago
elizoller 8eb7deec4c fix dependency injection 4 years ago
elizoller c44b957eae update messenger for d9 4 years ago
  1. 4
      .travis.yml
  2. 6
      composer.json
  3. 1
      drush.services.yml
  4. 53
      islandora.info.yml
  5. 15
      islandora.install
  6. 2
      islandora.module
  7. 2
      islandora.routing.yml
  8. 4
      islandora.services.yml
  9. 3
      modules/islandora_audio/islandora_audio.info.yml
  10. 6
      modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
  11. 6
      modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php
  12. 3
      modules/islandora_breadcrumbs/islandora_breadcrumbs.info.yml
  13. 2
      modules/islandora_core_feature/config/install/migrate_plus.migration.islandora_tags.yml
  14. 45
      modules/islandora_core_feature/islandora_core_feature.info.yml
  15. 3
      modules/islandora_iiif/islandora_iiif.info.yml
  16. 36
      modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php
  17. 18
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
  18. 3
      modules/islandora_image/islandora_image.info.yml
  19. 6
      modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
  20. 4
      modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
  21. 6
      modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php
  22. 3
      modules/islandora_text_extraction/islandora_text_extraction.info.yml
  23. 1
      modules/islandora_text_extraction/islandora_text_extraction.services.yml
  24. 10
      modules/islandora_text_extraction/src/Controller/MediaSourceController.php
  25. 4
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
  26. 6
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
  27. 66
      modules/islandora_text_extraction/src/Plugin/Field/FieldFormatter/OcrTextFormatter.php
  28. 21
      modules/islandora_text_extraction_defaults/islandora_text_extraction_defaults.info.yml
  29. 3
      modules/islandora_video/islandora_video.info.yml
  30. 6
      modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
  31. 6
      modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php
  32. 52
      phpunit.xml
  33. 50
      src/Commands/IslandoraCommands.php
  34. 8
      src/ContextProvider/FileContextProvider.php
  35. 8
      src/ContextProvider/FileRouteContextProvider.php
  36. 8
      src/ContextProvider/MediaContextProvider.php
  37. 8
      src/ContextProvider/MediaRouteContextProvider.php
  38. 8
      src/ContextProvider/NodeContextProvider.php
  39. 8
      src/ContextProvider/TermContextProvider.php
  40. 11
      src/ContextProvider/TermRouteContextProvider.php
  41. 2
      src/Controller/ManageMembersController.php
  42. 51
      src/EventGenerator/EmitEvent.php
  43. 3
      src/EventGenerator/EventGenerator.php
  44. 1
      src/EventSubscriber/LinkHeaderSubscriber.php
  45. 19
      src/Flysystem/Adapter/FedoraAdapter.php
  46. 1
      src/Form/ConfirmDeleteMediaAndFile.php
  47. 11
      src/Form/IslandoraSettingsForm.php
  48. 10
      src/GeminiLookup.php
  49. 32
      src/IslandoraUtils.php
  50. 14
      src/MediaSource/MediaSourceService.php
  51. 142
      src/Plugin/Action/AbstractGenerateDerivative.php
  52. 142
      src/Plugin/Action/AbstractGenerateDerivativeBase.php
  53. 140
      src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php
  54. 15
      src/Plugin/Action/EmitFileEvent.php
  55. 12
      src/Plugin/Action/EmitMediaEvent.php
  56. 3
      src/Plugin/Condition/FileUsesFilesystem.php
  57. 4
      src/Plugin/Condition/MediaHasMimetype.php
  58. 2
      src/Plugin/Condition/MediaSourceHasMimetype.php
  59. 4
      src/Plugin/Condition/NodeHadNamespace.php
  60. 8
      src/Plugin/Condition/NodeHasParent.php
  61. 4
      src/Plugin/Condition/NodeReferencedByNode.php
  62. 4
      src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php
  63. 2
      tests/modules/integer_weight_test_views/integer_weight_test_views.info.yml
  64. 1
      tests/modules/integer_weight_test_views/test_views/views.view.test_integer_weight.yml
  65. 16
      tests/src/Functional/AddMediaToNodeTest.php
  66. 5
      tests/src/Functional/ContentEntityTypeTest.php
  67. 6
      tests/src/Functional/DerivativeReactionTest.php
  68. 9
      tests/src/Functional/EmitNodeEventTest.php
  69. 2
      tests/src/Functional/EntityBundleTest.php
  70. 2
      tests/src/Functional/FormDisplayAlterReactionTest.php
  71. 2
      tests/src/Functional/IndexingTest.php
  72. 17
      tests/src/Functional/IslandoraFunctionalTestBase.php
  73. 6
      tests/src/Functional/IslandoraImageFormatterTest.php
  74. 16
      tests/src/Functional/IslandoraSettingsFormTest.php
  75. 6
      tests/src/Functional/JsonldSelfReferenceReactionTest.php
  76. 10
      tests/src/Functional/JsonldTypeAlterReactionTest.php
  77. 5
      tests/src/Functional/LinkHeaderTest.php
  78. 10
      tests/src/Functional/MediaSourceUpdateTest.php
  79. 4
      tests/src/Functional/ViewModeAlterReactionTest.php
  80. 7
      tests/src/FunctionalJavascript/IntegerWeightTest.php
  81. 68
      tests/src/Kernel/FedoraAdapterTest.php
  82. 5
      tests/src/Kernel/GeminiClientFactoryTest.php

4
.travis.yml

@ -1,8 +1,8 @@
sudo: true sudo: true
language: php language: php
php: php:
- 7.2
- 7.3 - 7.3
- 7.4
env: env:
- TESTSUITE=kernel - TESTSUITE=kernel
@ -11,8 +11,6 @@ env:
matrix: matrix:
fast_finish: true fast_finish: true
allow_failures:
- php: 7.3
services: services:
- mysql - mysql

6
composer.json

@ -14,7 +14,7 @@
} }
], ],
"require": { "require": {
"drupal/context": "^4.0", "drupal/context": "^4.0@beta",
"drupal/search_api": "~1.8", "drupal/search_api": "~1.8",
"islandora/jsonld": "dev-8.x-1.x", "islandora/jsonld": "dev-8.x-1.x",
"stomp-php/stomp-php": "4.*", "stomp-php/stomp-php": "4.*",
@ -25,9 +25,9 @@
"drupal/features" : "^3.7", "drupal/features" : "^3.7",
"drupal/migrate_plus" : "^5.1", "drupal/migrate_plus" : "^5.1",
"drupal/migrate_tools" : "^5.0", "drupal/migrate_tools" : "^5.0",
"drupal/migrate_source_csv" : "^2.1", "drupal/migrate_source_csv" : "^3.4",
"drupal/token" : "^1.3", "drupal/token" : "^1.3",
"drupal/flysystem" : "^1.0", "drupal/flysystem" : "^2.0@alpha",
"islandora/crayfish-commons": "dev-dev", "islandora/crayfish-commons": "dev-dev",
"drupal/file_replace": "^1.1" "drupal/file_replace": "^1.1"

1
drush.services.yml

@ -1,5 +1,6 @@
services: services:
islandora.commands: islandora.commands:
class: \Drupal\islandora\Commands\IslandoraCommands class: \Drupal\islandora\Commands\IslandoraCommands
arguments: ['@entity_type.manager', '@current_user', '@account_switcher']
tags: tags:
- { name: drush.command } - { name: drush.command }

53
islandora.info.yml

@ -5,30 +5,31 @@ description: "Islandora Core"
type: module type: module
package: Islandora package: Islandora
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
dependencies: dependencies:
- block - drupal:block
- node - drupal:node
- path - drupal:path
- text - drupal:text
- options - drupal:options
- link - drupal:link
- jsonld - drupal:jsonld
- search_api - drupal:search_api
- jwt - drupal:jwt
- rest - drupal:rest
- filehash - drupal:filehash
- basic_auth - drupal:basic_auth
- context_ui - drupal:context_ui
- action - drupal:action
- eva - drupal:eva
- taxonomy - drupal:taxonomy
- views_ui - drupal:views_ui
- media - drupal:media
- prepopulate - drupal:prepopulate
- features_ui - drupal:features_ui
- migrate_tools - drupal:migrate_tools
- migrate_source_csv - drupal:migrate_source_csv
- content_translation - drupal:content_translation
- flysystem - drupal:flysystem
- token - drupal:token
- file_replace - drupal:file_replace

15
islandora.install

@ -55,3 +55,18 @@ function islandora_update_8003(&$sandbox) {
->schema() ->schema()
->dropTable('islandora_version_count'); ->dropTable('islandora_version_count');
} }
/**
* Renames migration source keys -> ids.
*/
function islandora_update_8004() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('migrate_plus.migration.islandora__tags');
if ($config) {
if (!$config->get('source.ids')) {
$config->set('source.ids', $config->get('source.keys'));
$config->clear('source.keys');
$config->save(TRUE);
}
}
}

2
islandora.module

@ -205,7 +205,7 @@ function islandora_file_insert(FileInterface $file) {
*/ */
function islandora_file_update(FileInterface $file) { function islandora_file_update(FileInterface $file) {
// Exit early if unchanged. // Exit early if unchanged.
if ($file->filehash['sha1'] == $file->original->filehash['sha1']) { if ($file->filehash != NULL && $file->original->filehash != NULL && $file->filehash['sha1'] == $file->original->filehash['sha1']) {
return; return;
} }

2
islandora.routing.yml

@ -78,5 +78,3 @@ islandora.confirm_delete_media_and_file:
_form: 'Drupal\islandora\Form\ConfirmDeleteMediaAndFile' _form: 'Drupal\islandora\Form\ConfirmDeleteMediaAndFile'
requirements: requirements:
_permission: 'administer media+delete any media' _permission: 'administer media+delete any media'

4
islandora.services.yml

@ -48,10 +48,10 @@ 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', '@islandora.utils'] arguments: ['@entity_type.manager', '@current_user', '@language_manager', '@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', '@language_manager'] arguments: ['@entity_type.manager', '@entity_field.manager', '@context.manager', '@flysystem_factory', '@language_manager']
islandora.gemini.client: islandora.gemini.client:
class: Islandora\Crayfish\Commons\Client\GeminiClient class: Islandora\Crayfish\Commons\Client\GeminiClient
factory: ['Drupal\islandora\GeminiClientFactory', create] factory: ['Drupal\islandora\GeminiClientFactory', create]

3
modules/islandora_audio/islandora_audio.info.yml

@ -3,5 +3,6 @@ description: 'Islandora audio derivative actions'
type: module type: module
package: Islandora package: Islandora
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
dependencies: dependencies:
- islandora - drupal:islandora

6
modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php

@ -34,8 +34,8 @@ class GenerateAudioDerivative extends AbstractGenerateDerivative {
*/ */
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)'); $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)');
$form['args']['#description'] = t('Additional command line parameters for FFMpeg'); $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
return $form; return $form;
} }
@ -48,7 +48,7 @@ class GenerateAudioDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != 'audio') { if ($exploded_mime[0] != 'audio') {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter a audio mimetype (e.g. audio/mpeg, audio/m4a, etc...)') $this->t('Please enter a audio mimetype (e.g. audio/mpeg, audio/m4a, etc...)')
); );
} }
} }

6
modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php

@ -40,7 +40,7 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
// Create an action to generate a audio derivative. // Create an action to generate a audio derivative.
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a audio derivative"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a audio derivative");
$this->getSession()->getPage()->pressButton(t('Create')); $this->getSession()->getPage()->pressButton($this->t('Create'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->getSession()->getPage()->fillField('edit-label', "Generate audio test derivative"); $this->getSession()->getPage()->fillField('edit-label', "Generate audio test derivative");
@ -53,7 +53,7 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
$this->getSession()->getPage()->fillField('edit-args', "-f mp3"); $this->getSession()->getPage()->fillField('edit-args', "-f mp3");
$this->getSession()->getPage()->fillField('edit-scheme', "public"); $this->getSession()->getPage()->fillField('edit-scheme', "public");
$this->getSession()->getPage()->fillField('edit-path', "derp.mov"); $this->getSession()->getPage()->fillField('edit-path', "derp.mov");
$this->getSession()->getPage()->pressButton(t('Save')); $this->getSession()->getPage()->pressButton($this->t('Save'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Create a context and add the action as a derivative reaction. // Create a context and add the action as a derivative reaction.
@ -68,7 +68,7 @@ class GenerateAudioDerivativeTest extends GenerateDerivativeTestBase {
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_tags[0][target_id]' => 'Preservation Master',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, t('Save')); $this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save'));
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

3
modules/islandora_breadcrumbs/islandora_breadcrumbs.info.yml

@ -2,6 +2,7 @@ name: 'Islandora Breadcrumbs'
type: module type: module
description: 'Builds breadcrumbs based on field_member_of relationships.' description: 'Builds breadcrumbs based on field_member_of relationships.'
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
package: Islandora package: Islandora
dependencies: dependencies:
- islandora - drupal:islandora

2
modules/islandora_core_feature/config/install/migrate_plus.migration.islandora_tags.yml

@ -15,7 +15,7 @@ source:
plugin: csv plugin: csv
path: modules/contrib/islandora/migrate/tags.csv path: modules/contrib/islandora/migrate/tags.csv
header_row_count: 1 header_row_count: 1
keys: ids:
- external_uri - external_uri
process: process:
name: name name: name

45
modules/islandora_core_feature/islandora_core_feature.info.yml

@ -2,27 +2,28 @@ name: 'Islandora Core Feature'
description: 'Minimum configuration required for Islandora.' description: 'Minimum configuration required for Islandora.'
type: module type: module
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
dependencies: dependencies:
- basic_auth - drupal:basic_auth
- content_translation - drupal:content_translation
- eva - drupal:eva
- features - drupal:features
- field - drupal:field
- file - drupal:file
- filehash - drupal:filehash
- image - drupal:image
- islandora - drupal:islandora
- jsonld - drupal:jsonld
- jwt - drupal:jwt
- language - drupal:language
- link - drupal:link
- media - drupal:media
- migrate_plus - drupal:migrate_plus
- node - drupal:node
- rest - drupal:rest
- serialization - drupal:serialization
- system - drupal:system
- taxonomy - drupal:taxonomy
- user - drupal:user
- views - drupal:views
package: Islandora package: Islandora

3
modules/islandora_iiif/islandora_iiif.info.yml

@ -2,6 +2,7 @@ name: 'Islandora IIIF'
type: module type: module
description: 'IIIF support for Islandora' description: 'IIIF support for Islandora'
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
package: Islandora package: Islandora
dependencies: dependencies:
- islandora - drupal:islandora

36
modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php

@ -2,16 +2,49 @@
namespace Drupal\islandora_iiif\Form; namespace Drupal\islandora_iiif\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ClientException;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Form to configure IslandoraIIIF. * Form to configure IslandoraIIIF.
*/ */
class IslandoraIIIFConfigForm extends ConfigFormBase { class IslandoraIIIFConfigForm extends ConfigFormBase {
/**
* The HTTP client to fetch the files with.
*
* @var \GuzzleHttp\ClientInterface
*/
protected $httpClient;
/**
* IslandoraIIIFConfigForm constructor.
*
* @param \GuzzleHttp\ClientInterface $http_client
* A Guzzle client object.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
*/
public function __construct(ClientInterface $http_client, ConfigFactoryInterface $config_factory) {
parent::__construct($config_factory);
$this->httpClient = $http_client;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('http_client'),
$container->get('config.factory')
);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -78,9 +111,8 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
* True if server returns 200 on a HEAD request. * True if server returns 200 on a HEAD request.
*/ */
private function validateIiifUrl($server_uri) { private function validateIiifUrl($server_uri) {
$client = \Drupal::httpClient();
try { try {
$result = $client->head($server_uri); $result = $this->httpClient->head($server_uri);
return ($result->getStatusCode() == 200); return ($result->getStatusCode() == 200);
} }
catch (ClientException $e) { catch (ClientException $e) {

18
modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

@ -4,6 +4,7 @@ namespace Drupal\islandora_iiif\Plugin\views\style;
use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
@ -74,10 +75,17 @@ class IIIFManifest extends StylePluginBase {
*/ */
protected $fileSystem; protected $fileSystem;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, FileSystem $file_system, Client $http_client) { public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, FileSystem $file_system, Client $http_client, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->serializer = $serializer; $this->serializer = $serializer;
@ -85,6 +93,7 @@ class IIIFManifest extends StylePluginBase {
$this->iiifConfig = $iiif_config; $this->iiifConfig = $iiif_config;
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
$this->httpClient = $http_client; $this->httpClient = $http_client;
$this->messenger = $messenger;
} }
/** /**
@ -99,7 +108,8 @@ class IIIFManifest extends StylePluginBase {
$container->get('request_stack')->getCurrentRequest(), $container->get('request_stack')->getCurrentRequest(),
$container->get('config.factory')->get('islandora_iiif.settings'), $container->get('config.factory')->get('islandora_iiif.settings'),
$container->get('file_system'), $container->get('file_system'),
$container->get('http_client') $container->get('http_client'),
$container->get('messenger')
); );
} }
@ -176,7 +186,7 @@ class IIIFManifest extends StylePluginBase {
foreach ($images as $image) { foreach ($images as $image) {
// Create the IIIF URL for this file // Create the IIIF URL for this file
// Visiting $iiif_url will resolve to the info.json for the image. // Visiting $iiif_url will resolve to the info.json for the image.
$file_url = $image->entity->url(); $file_url = $image->entity->createFileUrl(FALSE);
$mime_type = $image->entity->getMimeType(); $mime_type = $image->entity->getMimeType();
$iiif_url = rtrim($iiif_address, '/') . '/' . urlencode($file_url); $iiif_url = rtrim($iiif_address, '/') . '/' . urlencode($file_url);
@ -297,7 +307,7 @@ class IIIFManifest extends StylePluginBase {
// If no fields to choose from, add an error message indicating such. // If no fields to choose from, add an error message indicating such.
if (count($field_options) == 0) { if (count($field_options) == 0) {
drupal_set_message($this->t('No image or file fields were found in the View. $this->messenger->addMessage($this->t('No image or file fields were found in the View.
You will need to add a field to this View'), 'error'); You will need to add a field to this View'), 'error');
} }

3
modules/islandora_image/islandora_image.info.yml

@ -2,6 +2,7 @@ name: 'Islandora Image'
type: module type: module
description: 'Islandora Image derivative actions' description: 'Islandora Image derivative actions'
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
package: Islandora package: Islandora
dependencies: dependencies:
- islandora - drupal:islandora

6
modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php

@ -32,8 +32,8 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
*/ */
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. image/jpeg, image/png, etc...)'); $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. image/jpeg, image/png, etc...)');
$form['args']['#description'] = t('Additional command line arguments for ImageMagick convert (e.g. -resize 50%'); $form['args']['#description'] = $this->t('Additional command line arguments for ImageMagick convert (e.g. -resize 50%');
return $form; return $form;
} }
@ -48,7 +48,7 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != "image") { if ($exploded_mime[0] != "image") {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter an image mimetype (e.g. image/jpeg, image/png, etc...)') $this->t('Please enter an image mimetype (e.g. image/jpeg, image/png, etc...)')
); );
} }
} }

4
modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php

@ -25,7 +25,7 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
$config['mimetype'] = 'application/xml'; $config['mimetype'] = 'application/xml';
$config['queue'] = 'islandora-connector-houdini'; $config['queue'] = 'islandora-connector-houdini';
$config['destination_media_type'] = 'file'; $config['destination_media_type'] = 'file';
$config['scheme'] = file_default_scheme(); $config['scheme'] = $this->config->get('default_scheme');
return $config; return $config;
} }
@ -34,7 +34,7 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
*/ */
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. application/xml, etc...)'); $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. application/xml, etc...)');
$form['mimetype']['#value'] = 'image/jpeg'; $form['mimetype']['#value'] = 'image/jpeg';
$form['mimetype']['#type'] = 'hidden'; $form['mimetype']['#type'] = 'hidden';
return $form; return $form;

6
modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php

@ -42,7 +42,7 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
// Create an action to generate a jpeg thumbnail. // Create an action to generate a jpeg thumbnail.
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Generate an image derivative"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Generate an image derivative");
$this->getSession()->getPage()->pressButton(t('Create')); $this->getSession()->getPage()->pressButton($this->t('Create'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->getSession()->getPage()->fillField('edit-label', "Generate image test derivative"); $this->getSession()->getPage()->fillField('edit-label', "Generate image test derivative");
@ -55,7 +55,7 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
$this->getSession()->getPage()->fillField('edit-args', "-thumbnail 20x20"); $this->getSession()->getPage()->fillField('edit-args', "-thumbnail 20x20");
$this->getSession()->getPage()->fillField('edit-scheme', "public"); $this->getSession()->getPage()->fillField('edit-scheme', "public");
$this->getSession()->getPage()->fillField('edit-path', "derp.jpeg"); $this->getSession()->getPage()->fillField('edit-path', "derp.jpeg");
$this->getSession()->getPage()->pressButton(t('Save')); $this->getSession()->getPage()->pressButton($this->t('Save'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Create a context and add the action as a derivative reaction. // Create a context and add the action as a derivative reaction.
@ -70,7 +70,7 @@ class GenerateImageDerivativeTest extends GenerateDerivativeTestBase {
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_tags[0][target_id]' => 'Preservation Master',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, t('Save')); $this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save'));
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

3
modules/islandora_text_extraction/islandora_text_extraction.info.yml

@ -2,6 +2,7 @@ name: 'Islandora Text Extraction'
type: module type: module
description: 'Islandora 8 module to connect to Hypercube microservice, and to get text from PDF ingest' description: 'Islandora 8 module to connect to Hypercube microservice, and to get text from PDF ingest'
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
package: 'Islandora' package: 'Islandora'
dependencies: dependencies:
- islandora - drupal:islandora

1
modules/islandora_text_extraction/islandora_text_extraction.services.yml

@ -5,4 +5,3 @@ services:
islandora_text_extraction.search_reindexer: islandora_text_extraction.search_reindexer:
class: Drupal\islandora_text_extraction\SearchReindexer class: Drupal\islandora_text_extraction\SearchReindexer
arguments: ['@islandora.utils', '@logger.channel.islandora_text_extraction'] arguments: ['@islandora.utils', '@logger.channel.islandora_text_extraction']

10
modules/islandora_text_extraction/src/Controller/MediaSourceController.php

@ -3,11 +3,13 @@
namespace Drupal\islandora_text_extraction\Controller; namespace Drupal\islandora_text_extraction\Controller;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\File\FileSystem;
use Drupal\Core\File\FileSystemInterface;
use Drupal\media\Entity\Media; use Drupal\media\Entity\Media;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\File\FileSystem; use Symfony\Component\HttpKernel\Exception\HttpException;
/** /**
* Controller for Media Source. * Controller for Media Source.
@ -93,10 +95,10 @@ class MediaSourceController extends ControllerBase {
if ($contents) { if ($contents) {
$directory = $this->fileSystem->dirname($content_location); $directory = $this->fileSystem->dirname($content_location);
if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { if (!$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable"); throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable");
} }
$file = file_save_data($contents, $content_location, FILE_EXISTS_REPLACE); $file = file_save_data($contents, $content_location, FileSystemInterface::EXISTS_REPLACE);
if ($media->hasField($destination_field)) { if ($media->hasField($destination_field)) {
$media->{$destination_field}->setValue([ $media->{$destination_field}->setValue([
'target_id' => $file->id(), 'target_id' => $file->id(),

4
modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php

@ -33,7 +33,7 @@ class GenerateOCRDerivative extends AbstractGenerateDerivative {
*/ */
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. application/xml, etc...)'); $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. application/xml, etc...)');
$form['mimetype']['#value'] = 'text/plain'; $form['mimetype']['#value'] = 'text/plain';
$form['mimetype']['#type'] = 'textfield'; $form['mimetype']['#type'] = 'textfield';
@ -50,7 +50,7 @@ class GenerateOCRDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != 'text') { if ($exploded_mime[0] != 'text') {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter file mimetype (e.g. text/plain.)') $this->t('Please enter file mimetype (e.g. text/plain.)')
); );
} }
} }

6
modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php

@ -27,7 +27,7 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
$config['mimetype'] = 'application/xml'; $config['mimetype'] = 'application/xml';
$config['queue'] = 'islandora-connector-ocr'; $config['queue'] = 'islandora-connector-ocr';
$config['destination_media_type'] = 'file'; $config['destination_media_type'] = 'file';
$config['scheme'] = file_default_scheme(); $config['scheme'] = $this->config->get('default_scheme');
$config['destination_text_field_name'] = ''; $config['destination_text_field_name'] = '';
return $config; return $config;
} }
@ -40,7 +40,7 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
$file_fields = $map['media']; $file_fields = $map['media'];
$field_options = array_combine(array_keys($file_fields), array_keys($file_fields)); $field_options = array_combine(array_keys($file_fields), array_keys($file_fields));
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. application/xml, etc...)'); $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. application/xml, etc...)');
$form['mimetype']['#value'] = 'text/plain'; $form['mimetype']['#value'] = 'text/plain';
$form['mimetype']['#type'] = 'hidden'; $form['mimetype']['#type'] = 'hidden';
$position = array_search('destination_field_name', array_keys($form)); $position = array_search('destination_field_name', array_keys($form));
@ -70,7 +70,7 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
if ($exploded_mime[0] != 'text') { if ($exploded_mime[0] != 'text') {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter file mimetype (e.g. application/xml.)') $this->t('Please enter file mimetype (e.g. application/xml.)')
); );
} }
} }

66
modules/islandora_text_extraction/src/Plugin/Field/FieldFormatter/OcrTextFormatter.php

@ -2,11 +2,16 @@
namespace Drupal\islandora_text_extraction\Plugin\Field\FieldFormatter; namespace Drupal\islandora_text_extraction\Plugin\Field\FieldFormatter;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemInterface;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Entity\File; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\RendererInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Plugin implementation of the 'ocr_txt_formatter' formatter. * Plugin implementation of the 'ocr_txt_formatter' formatter.
@ -17,7 +22,62 @@ use Drupal\file\Entity\File;
* field_types = {"file"} * field_types = {"file"}
* ) * )
*/ */
class OcrTextFormatter extends FormatterBase { class OcrTextFormatter extends FormatterBase implements ContainerFactoryPluginInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* OcrTextFormatter constructor.
*
* @param string $plugin_id
* The plugin_id for the formatter.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The definition of the field to which the formatter is associated.
* @param array $settings
* The formatter settings.
* @param string $label
* The formatter label display setting.
* @param string $view_mode
* The view mode.
* @param array $third_party_settings
* Third party settings.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, RendererInterface $renderer, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $renderer, $config_factory);
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings'],
$container->get('renderer'),
$container->get('config.factory'),
$container->get('entity_type.manager')
);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -70,7 +130,7 @@ class OcrTextFormatter extends FormatterBase {
*/ */
protected function viewValue(FieldItemInterface $item) { protected function viewValue(FieldItemInterface $item) {
$fileItem = $item->getValue(); $fileItem = $item->getValue();
$file = File::load($fileItem['target_id']); $file = $this->entityTypeManager->getStorage('file')->load($fileItem['target_id']);
$contents = file_get_contents($file->getFileUri()); $contents = file_get_contents($file->getFileUri());
if (mb_detect_encoding($contents) != 'UTF-8') { if (mb_detect_encoding($contents) != 'UTF-8') {
$contents = utf8_encode($contents); $contents = utf8_encode($contents);

21
modules/islandora_text_extraction_defaults/islandora_text_extraction_defaults.info.yml

@ -2,15 +2,16 @@ name: 'Islandora Text Extraction Defaults'
type: module type: module
description: 'Default config for the Islandora Text Extraction module.' description: 'Default config for the Islandora Text Extraction module.'
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
package: Islandora package: Islandora
dependencies: dependencies:
- field - drupal:field
- file - drupal:file
- islandora_core_feature - drupal:islandora_core_feature
- islandora_text_extraction - drupal:islandora_text_extraction
- language - drupal:language
- media - drupal:media
- path - drupal:path
- system - drupal:system
- text - drupal:text
- user - drupal:user

3
modules/islandora_video/islandora_video.info.yml

@ -3,5 +3,6 @@ description: 'Islandora video derivative actions'
type: module type: module
package: Islandora package: Islandora
core: 8.x core: 8.x
core_version_requirement: ^8 || ^9
dependencies: dependencies:
- islandora - drupal:islandora

6
modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php

@ -33,8 +33,8 @@ class GenerateVideoDerivative extends AbstractGenerateDerivative {
*/ */
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. video/mp4, video/quicktime, etc...)'); $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. video/mp4, video/quicktime, etc...)');
$form['args']['#description'] = t('Additional command line parameters for FFMpeg'); $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
return $form; return $form;
} }
@ -47,7 +47,7 @@ class GenerateVideoDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != 'video') { if ($exploded_mime[0] != 'video') {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter a video mimetype (e.g. video/mp4, video/quicktime, etc...)') $this->t('Please enter a video mimetype (e.g. video/mp4, video/quicktime, etc...)')
); );
} }
} }

6
modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php

@ -37,7 +37,7 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
// Create an action to generate a jpeg thumbnail. // Create an action to generate a jpeg thumbnail.
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a video derivative"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a video derivative");
$this->getSession()->getPage()->pressButton(t('Create')); $this->getSession()->getPage()->pressButton($this->t('Create'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$this->getSession()->getPage()->fillField('edit-label', "Generate video test derivative"); $this->getSession()->getPage()->fillField('edit-label', "Generate video test derivative");
@ -50,7 +50,7 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
$this->getSession()->getPage()->fillField('edit-args', "-f mp4"); $this->getSession()->getPage()->fillField('edit-args', "-f mp4");
$this->getSession()->getPage()->fillField('edit-scheme', "public"); $this->getSession()->getPage()->fillField('edit-scheme', "public");
$this->getSession()->getPage()->fillField('edit-path', "derp.mov"); $this->getSession()->getPage()->fillField('edit-path', "derp.mov");
$this->getSession()->getPage()->pressButton(t('Save')); $this->getSession()->getPage()->pressButton($this->t('Save'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Create a context and add the action as a derivative reaction. // Create a context and add the action as a derivative reaction.
@ -65,7 +65,7 @@ class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
'field_tags[0][target_id]' => 'Preservation Master', 'field_tags[0][target_id]' => 'Preservation Master',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, t('Save')); $this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save'));
$expected = [ $expected = [
'source_uri' => 'test_file.txt', 'source_uri' => 'test_file.txt',

52
phpunit.xml

@ -1,15 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. --> <!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user <!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details. https://www.drupal.org/node/2116263 for details.
--> -->
<phpunit bootstrap="tests/bootstrap.php" colors="true" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" beStrictAboutChangesToGlobalState="true" printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
beStrictAboutTestsThatDoNotTestAnything="true" <coverage>
beStrictAboutOutputDuringTests="true" <include>
beStrictAboutChangesToGlobalState="true" <directory>./includes</directory>
printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"> <directory>./lib</directory>
<directory>./modules</directory>
<directory>../modules</directory>
<directory>../sites</directory>
</include>
<exclude>
<directory>./modules/*/src/Tests</directory>
<directory>./modules/*/tests</directory>
<directory>../modules/*/src/Tests</directory>
<directory>../modules/*/tests</directory>
<directory>../modules/*/*/src/Tests</directory>
<directory>../modules/*/*/tests</directory>
</exclude>
</coverage>
<php> <php>
<!-- Set error reporting to E_ALL. --> <!-- Set error reporting to E_ALL. -->
<ini name="error_reporting" value="32767"/> <ini name="error_reporting" value="32767"/>
@ -29,13 +41,13 @@
<!-- To disable deprecation testing completely uncomment the next line. --> <!-- To disable deprecation testing completely uncomment the next line. -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
<!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' --> <!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' -->
<env name="MINK_DRIVER_CLASS" value=''/> <env name="MINK_DRIVER_CLASS" value=""/>
<!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' --> <!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS" value=''/> <env name="MINK_DRIVER_ARGS" value=""/>
<!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' --> <!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS_PHANTOMJS" value=''/> <env name="MINK_DRIVER_ARGS_PHANTOMJS" value=""/>
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" --> <!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/> <env name="MINK_DRIVER_ARGS_WEBDRIVER" value=""/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="unit"> <testsuite name="unit">
@ -63,24 +75,4 @@
</listener> </listener>
</listeners> </listeners>
<!-- Filter for coverage reports. --> <!-- Filter for coverage reports. -->
<filter>
<whitelist>
<directory>./includes</directory>
<directory>./lib</directory>
<!-- Extensions can have their own test directories, so exclude those. -->
<directory>./modules</directory>
<exclude>
<directory>./modules/*/src/Tests</directory>
<directory>./modules/*/tests</directory>
</exclude>
<directory>../modules</directory>
<exclude>
<directory>../modules/*/src/Tests</directory>
<directory>../modules/*/tests</directory>
<directory>../modules/*/*/src/Tests</directory>
<directory>../modules/*/*/tests</directory>
</exclude>
<directory>../sites</directory>
</whitelist>
</filter>
</phpunit> </phpunit>

50
src/Commands/IslandoraCommands.php

@ -3,8 +3,10 @@
namespace Drupal\islandora\Commands; namespace Drupal\islandora\Commands;
use Consolidation\AnnotatedCommand\CommandData; use Consolidation\AnnotatedCommand\CommandData;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountProxy;
use Drupal\Core\Session\AccountSwitcherInterface;
use Drupal\Core\Session\UserSession; use Drupal\Core\Session\UserSession;
use Drupal\user\Entity\User;
use Drush\Commands\DrushCommands; use Drush\Commands\DrushCommands;
/** /**
@ -13,6 +15,35 @@ use Drush\Commands\DrushCommands;
* ... because the --user option was removed from drush 9. * ... because the --user option was removed from drush 9.
*/ */
class IslandoraCommands extends DrushCommands { class IslandoraCommands extends DrushCommands {
/**
* Entity type manager object.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Drupal\Core\Session\AccountProxy definition.
*
* @var \Drupal\Core\Session\AccountProxy
*/
protected $currentUser;
/**
* The account switcher service.
*
* @var \Drupal\Core\Session\AccountSwitcherInterface
*/
protected $accountSwitcher;
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountProxy $current_user, AccountSwitcherInterface $account_switcher) {
$this->entityTypeManager = $entity_type_manager;
$this->currentUser = $current_user;
$this->accountSwitcher = $account_switcher;
}
/** /**
* Add the userid option. * Add the userid option.
@ -56,7 +87,8 @@ class IslandoraCommands extends DrushCommands {
protected function validateUser(CommandData $commandData) { protected function validateUser(CommandData $commandData) {
$userid = $commandData->input()->getOption('userid'); $userid = $commandData->input()->getOption('userid');
if ($userid) { if ($userid) {
$account = User::load($userid); $account =
$this->entityTypeManager->getStorage('user')->load($userid);
if (!$account) { if (!$account) {
throw new \Exception("User ID does not match an existing user."); throw new \Exception("User ID does not match an existing user.");
} }
@ -87,18 +119,17 @@ class IslandoraCommands extends DrushCommands {
protected function switchUser(CommandData $commandData) { protected function switchUser(CommandData $commandData) {
$userid = $commandData->input()->getOption('userid'); $userid = $commandData->input()->getOption('userid');
if ($userid) { if ($userid) {
$account = User::load($userid); $account = $this->entityTypeManager->getStorage('user')->load($userid);
$accountSwitcher = \Drupal::service('account_switcher');
$userSession = new UserSession([ $userSession = new UserSession([
'uid' => $account->id(), 'uid' => $account->id(),
'name' => $account->getUsername(), 'name' => $account->getDisplayName(),
'roles' => $account->getRoles(), 'roles' => $account->getRoles(),
]); ]);
$accountSwitcher->switchTo($userSession); $this->accountSwitcher->switchTo($userSession);
$this->logger()->notice( $this->logger()->notice(
dt( dt(
'Now acting as user ID @id', 'Now acting as user ID @id',
['@id' => \Drupal::currentUser()->id()] ['@id' => $this->currentUser->id()]
) )
); );
} }
@ -127,12 +158,11 @@ class IslandoraCommands extends DrushCommands {
*/ */
protected function switchUserBack(CommandData $commandData) { protected function switchUserBack(CommandData $commandData) {
if ($commandData->input()->getOption('userid')) { if ($commandData->input()->getOption('userid')) {
$accountSwitcher = \Drupal::service('account_switcher');
$this->logger()->notice(dt( $this->logger()->notice(dt(
'Switching back from user @uid.', 'Switching back from user @uid.',
['@uid' => \Drupal::currentUser()->id()] ['@uid' => $this->currentUser->id()]
)); ));
$accountSwitcher->switchBack(); $this->accountSwitcher->switchBack();
} }
} }

8
src/ContextProvider/FileContextProvider.php

@ -3,9 +3,8 @@
namespace Drupal\islandora\ContextProvider; namespace Drupal\islandora\ContextProvider;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
/** /**
@ -36,8 +35,7 @@ class FileContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRuntimeContexts(array $unqualified_context_ids) { public function getRuntimeContexts(array $unqualified_context_ids) {
$context_definition = new ContextDefinition('entity:file', NULL, FALSE); $context = EntityContext::fromEntity($this->file);
$context = new Context($context_definition, $this->file);
return ['@islandora.file_route_context_provider:file' => $context]; return ['@islandora.file_route_context_provider:file' => $context];
} }
@ -45,7 +43,7 @@ class FileContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getAvailableContexts() { public function getAvailableContexts() {
$context = new Context(new ContextDefinition('entity:file', $this->t('File from entity hook'))); $context = EntityContext::fromEntityTypeId('file', $this->t('File from entity hook'));
return ['@islandora.file_route_context_provider:file' => $context]; return ['@islandora.file_route_context_provider:file' => $context];
} }

8
src/ContextProvider/FileRouteContextProvider.php

@ -4,8 +4,9 @@ namespace Drupal\islandora\ContextProvider;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Plugin\Context\Context; use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
@ -37,7 +38,8 @@ class FileRouteContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRuntimeContexts(array $unqualified_context_ids) { public function getRuntimeContexts(array $unqualified_context_ids) {
$context_definition = new ContextDefinition('entity:file', NULL, FALSE); $context_definition = EntityContextDefinition::fromEntityTypeId('file')->setLabel(NULL)->setRequired(FALSE);
$value = NULL; $value = NULL;
// Hack the file out of the route. // Hack the file out of the route.
@ -64,7 +66,7 @@ class FileRouteContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getAvailableContexts() { public function getAvailableContexts() {
$context = new Context(new ContextDefinition('entity:file', $this->t('File from URL'))); $context = EntityContext::fromEntityTypeId('file', $this->t('File from URL'));
return ['file' => $context]; return ['file' => $context];
} }

8
src/ContextProvider/MediaContextProvider.php

@ -3,9 +3,8 @@
namespace Drupal\islandora\ContextProvider; namespace Drupal\islandora\ContextProvider;
use Drupal\media\MediaInterface; use Drupal\media\MediaInterface;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
/** /**
@ -36,8 +35,7 @@ class MediaContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRuntimeContexts(array $unqualified_context_ids) { public function getRuntimeContexts(array $unqualified_context_ids) {
$context_definition = new ContextDefinition('entity:media', NULL, FALSE); $context = EntityContext::fromEntity($this->media);
$context = new Context($context_definition, $this->media);
return ['@islandora.media_route_context_provider:media' => $context]; return ['@islandora.media_route_context_provider:media' => $context];
} }
@ -45,7 +43,7 @@ class MediaContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getAvailableContexts() { public function getAvailableContexts() {
$context = new Context(new ContextDefinition('entity:media', $this->t('Media from entity hook'))); $context = EntityContext::fromEntityType(\Drupal::entityTypeManager()->getDefinition('media'), $this->t('Media from URL'));
return ['@islandora.media_route_context_provider:media' => $context]; return ['@islandora.media_route_context_provider:media' => $context];
} }

8
src/ContextProvider/MediaRouteContextProvider.php

@ -4,8 +4,9 @@ namespace Drupal\islandora\ContextProvider;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Plugin\Context\Context; use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\media\Entity\Media; use Drupal\media\Entity\Media;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
@ -38,8 +39,7 @@ class MediaRouteContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRuntimeContexts(array $unqualified_context_ids) { public function getRuntimeContexts(array $unqualified_context_ids) {
$result = []; $context_definition = EntityContextDefinition::fromEntityTypeId('media')->setLabel(NULL)->setRequired(FALSE);
$context_definition = new ContextDefinition('entity:media', NULL, FALSE);
$value = NULL; $value = NULL;
// Hack the media out of the route. // Hack the media out of the route.
@ -70,7 +70,7 @@ class MediaRouteContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getAvailableContexts() { public function getAvailableContexts() {
$context = new Context(new ContextDefinition('entity:media', $this->t('Media from URL'))); $context = EntityContext::fromEntityType(\Drupal::entityTypeManager()->getDefinition('media'), $this->t('Media from URL'));
return ['media' => $context]; return ['media' => $context];
} }

8
src/ContextProvider/NodeContextProvider.php

@ -3,9 +3,8 @@
namespace Drupal\islandora\ContextProvider; namespace Drupal\islandora\ContextProvider;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
/** /**
@ -36,8 +35,7 @@ class NodeContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRuntimeContexts(array $unqualified_context_ids) { public function getRuntimeContexts(array $unqualified_context_ids) {
$context_definition = new ContextDefinition('entity:node', NULL, FALSE); $context = EntityContext::fromEntity($this->node);
$context = new Context($context_definition, $this->node);
return ['@node.node_route_context:node' => $context]; return ['@node.node_route_context:node' => $context];
} }
@ -45,7 +43,7 @@ class NodeContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getAvailableContexts() { public function getAvailableContexts() {
$context = new Context(new ContextDefinition('entity:node', $this->t('Node from entity hook'))); $context = EntityContext::fromEntityTypeId('node', $this->t('Node from entity hook'));
return ['@node.node_route_context:node' => $context]; return ['@node.node_route_context:node' => $context];
} }

8
src/ContextProvider/TermContextProvider.php

@ -3,9 +3,8 @@
namespace Drupal\islandora\ContextProvider; namespace Drupal\islandora\ContextProvider;
use Drupal\taxonomy\TermInterface; use Drupal\taxonomy\TermInterface;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
/** /**
@ -36,8 +35,7 @@ class TermContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRuntimeContexts(array $unqualified_context_ids) { public function getRuntimeContexts(array $unqualified_context_ids) {
$context_definition = new ContextDefinition('entity:taxonomy_term', NULL, FALSE); $context = EntityContext::fromEntity($this->term);
$context = new Context($context_definition, $this->term);
return ['@islandora.taxonomy_term_route_context_provider:taxonomy_term' => $context]; return ['@islandora.taxonomy_term_route_context_provider:taxonomy_term' => $context];
} }
@ -45,7 +43,7 @@ class TermContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getAvailableContexts() { public function getAvailableContexts() {
$context = new Context(new ContextDefinition('entity:taxonomy_term', $this->t('Term from entity hook'))); $context = EntityContext::fromEntityTypeId('taxonomy_term', $this->t('Term from entity hook'));
return ['@islandora.taxonomy_term_route_context_provider:taxonomy_term' => $context]; return ['@islandora.taxonomy_term_route_context_provider:taxonomy_term' => $context];
} }

11
src/ContextProvider/TermRouteContextProvider.php

@ -4,8 +4,9 @@ namespace Drupal\islandora\ContextProvider;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Plugin\Context\Context; use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Plugin\Context\EntityContext;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
@ -24,7 +25,7 @@ class TermRouteContextProvider implements ContextProviderInterface {
protected $routeMatch; protected $routeMatch;
/** /**
* Constructs a new FileRouteContextProvider. * Constructs a new TermRouteContextProvider.
* *
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match object. * The route match object.
@ -37,10 +38,10 @@ class TermRouteContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getRuntimeContexts(array $unqualified_context_ids) { public function getRuntimeContexts(array $unqualified_context_ids) {
$context_definition = new ContextDefinition('entity:taxonomy_term', NULL, FALSE); $context_definition = EntityContextDefinition::fromEntityTypeId('taxonomy_term')->setLabel(NULL)->setRequired(FALSE);
$value = NULL; $value = NULL;
// Hack the file out of the route. // Hack the taxonomy term out of the route.
$route_object = $this->routeMatch->getRouteObject(); $route_object = $this->routeMatch->getRouteObject();
if ($route_object) { if ($route_object) {
$route_contexts = $route_object->getOption('parameters'); $route_contexts = $route_object->getOption('parameters');
@ -64,7 +65,7 @@ class TermRouteContextProvider implements ContextProviderInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getAvailableContexts() { public function getAvailableContexts() {
$context = new Context(new ContextDefinition('entity:taxonomy_term', $this->t('Term from URL'))); $context = EntityContext::fromEntityTypeId('taxonomy_term', $this->t('Term from URL'));
return ['taxonomy_term' => $context]; return ['taxonomy_term' => $context];
} }

2
src/Controller/ManageMembersController.php

@ -130,7 +130,7 @@ class ManageMembersController extends EntityController {
} }
// Build the message shown when there are no bundles. // Build the message shown when there are no bundles.
$type_label = $type_definition->getLowercaseLabel(); $type_label = $type_definition->getSingularLabel();
$link_text = $this->t('Add a new @entity_type.', ['@entity_type' => $type_label]); $link_text = $this->t('Add a new @entity_type.', ['@entity_type' => $type_label]);
$build['#add_bundle_message'] = $this->t('There is no @entity_type yet. @add_link', [ $build['#add_bundle_message'] = $this->t('There is no @entity_type yet. @add_link', [
'@entity_type' => $type_label, '@entity_type' => $type_label,

51
src/EventGenerator/EmitEvent.php

@ -5,10 +5,12 @@ namespace Drupal\islandora\EventGenerator;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Action\ConfigurableActionBase; use Drupal\Core\Action\ConfigurableActionBase;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use Stomp\Exception\StompException; use Stomp\Exception\StompException;
use Stomp\StatefulStomp; use Stomp\StatefulStomp;
@ -19,6 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* Configurable action base for actions that publish messages to queues. * Configurable action base for actions that publish messages to queues.
*/ */
abstract class EmitEvent extends ConfigurableActionBase implements ContainerFactoryPluginInterface { abstract class EmitEvent extends ConfigurableActionBase implements ContainerFactoryPluginInterface {
use StringTranslationTrait;
/** /**
* Current user. * Current user.
@ -55,6 +58,13 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
*/ */
protected $auth; protected $auth;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/** /**
* Constructs a EmitEvent action. * Constructs a EmitEvent action.
* *
@ -74,6 +84,8 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
* Stomp client. * Stomp client.
* @param \Drupal\jwt\Authentication\Provider\JwtAuth $auth * @param \Drupal\jwt\Authentication\Provider\JwtAuth $auth
* JWT Auth client. * JWT Auth client.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -83,7 +95,8 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
EntityTypeManagerInterface $entity_type_manager, EntityTypeManagerInterface $entity_type_manager,
EventGeneratorInterface $event_generator, EventGeneratorInterface $event_generator,
StatefulStomp $stomp, StatefulStomp $stomp,
JwtAuth $auth JwtAuth $auth,
MessengerInterface $messenger
) { ) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->account = $account; $this->account = $account;
@ -91,6 +104,7 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
$this->eventGenerator = $event_generator; $this->eventGenerator = $event_generator;
$this->stomp = $stomp; $this->stomp = $stomp;
$this->auth = $auth; $this->auth = $auth;
$this->messenger = $messenger;
} }
/** /**
@ -105,7 +119,8 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
$container->get('entity_type.manager'), $container->get('entity_type.manager'),
$container->get('islandora.eventgenerator'), $container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'), $container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt') $container->get('jwt.authentication.jwt'),
$container->get('messenger')
); );
} }
@ -119,10 +134,10 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
if (empty($token)) { if (empty($token)) {
// JWT isn't properly configured. Log and notify user. // JWT isn't properly configured. Log and notify user.
\Drupal::logger('islandora')->error( \Drupal::logger('islandora')->error(
t('Error getting JWT token for message. Check JWT Configuration.') $this->t('Error getting JWT token for message. Check JWT Configuration.')
); );
drupal_set_message( $this->messenger->addMessage(
t('Error getting JWT token for message. Check JWT Configuration.'), 'error' $this->t('Error getting JWT token for message. Check JWT Configuration.'), 'error'
); );
return; return;
} }
@ -139,10 +154,10 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
catch (\RuntimeException $e) { catch (\RuntimeException $e) {
// Notify the user the event couldn't be generated and abort. // Notify the user the event couldn't be generated and abort.
\Drupal::logger('islandora')->error( \Drupal::logger('islandora')->error(
t('Error generating event: @msg', ['@msg' => $e->getMessage()]) $this->t('Error generating event: @msg', ['@msg' => $e->getMessage()])
); );
drupal_set_message( $this->messenger->addMessage(
t('Error generating event: @msg', ['@msg' => $e->getMessage()]), $this->t('Error generating event: @msg', ['@msg' => $e->getMessage()]),
'error' 'error'
); );
return; return;
@ -162,8 +177,8 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
); );
// Notify user. // Notify user.
drupal_set_message( $this->messenger->addMessage(
t('Error publishing message: @msg', $this->t('Error publishing message: @msg',
['@msg' => $e->getMessage()] ['@msg' => $e->getMessage()]
), ),
'error' 'error'
@ -194,22 +209,22 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['queue'] = [ $form['queue'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Queue'), '#title' => $this->t('Queue'),
'#default_value' => $this->configuration['queue'], '#default_value' => $this->configuration['queue'],
'#required' => TRUE, '#required' => TRUE,
'#rows' => '8', '#rows' => '8',
'#description' => t('Name of queue to which event is published'), '#description' => $this->t('Name of queue to which event is published'),
]; ];
$form['event'] = [ $form['event'] = [
'#type' => 'select', '#type' => 'select',
'#title' => t('Event type'), '#title' => $this->t('Event type'),
'#default_value' => $this->configuration['event'], '#default_value' => $this->configuration['event'],
'#description' => t('Type of event to emit'), '#description' => $this->t('Type of event to emit'),
'#options' => [ '#options' => [
'Create' => t('Create'), 'Create' => $this->t('Create'),
'Update' => t('Update'), 'Update' => $this->t('Update'),
'Delete' => t('Delete'), 'Delete' => $this->t('Delete'),
'Generate Derivative' => t('Generate Derivative'), 'Generate Derivative' => $this->t('Generate Derivative'),
], ],
]; ];
return $form; return $form;

3
src/EventGenerator/EventGenerator.php

@ -92,11 +92,12 @@ class EventGenerator implements EventGeneratorInterface {
]; ];
$flysystem_config = Settings::get('flysystem'); $flysystem_config = Settings::get('flysystem');
if ($flysystem_config != NULL && array_key_exists('fedora', $flysystem_config)) {
$fedora_url = $flysystem_config['fedora']['config']['root']; $fedora_url = $flysystem_config['fedora']['config']['root'];
$event["target"] = $fedora_url; $event["target"] = $fedora_url;
}
$entity_type = $entity->getEntityTypeId(); $entity_type = $entity->getEntityTypeId();
$event_type = $data["event"];
if ($data["event"] == "Generate Derivative") { if ($data["event"] == "Generate Derivative") {
$event["type"] = "Activity"; $event["type"] = "Activity";
$event["summary"] = $data["event"]; $event["summary"] = $data["event"];

1
src/EventSubscriber/LinkHeaderSubscriber.php

@ -263,7 +263,6 @@ abstract class LinkHeaderSubscriber implements EventSubscriberInterface {
$current_format = $this->requestStack->getCurrentRequest()->query->get('_format'); $current_format = $this->requestStack->getCurrentRequest()->query->get('_format');
$links = []; $links = [];
$route_name = $this->routeMatch->getRouteName();
if ($rest_resource_config) { if ($rest_resource_config) {
$formats = $rest_resource_config->getFormats("GET"); $formats = $rest_resource_config->getFormats("GET");

19
src/Flysystem/Adapter/FedoraAdapter.php

@ -7,7 +7,6 @@ use League\Flysystem\AdapterInterface;
use League\Flysystem\Adapter\Polyfill\NotSupportingVisibilityTrait; use League\Flysystem\Adapter\Polyfill\NotSupportingVisibilityTrait;
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait; use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
use League\Flysystem\Config; use League\Flysystem\Config;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\StreamWrapper; use GuzzleHttp\Psr7\StreamWrapper;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
@ -144,7 +143,14 @@ class FedoraAdapter implements AdapterInterface {
// NonRDFSource's are considered files. Everything else is a // NonRDFSource's are considered files. Everything else is a
// directory. // directory.
$type = 'dir'; $type = 'dir';
$links = Psr7\parse_header($response->getHeader('Link')); // phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$links = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link'));
}
else {
$links = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
}
// phpcs:enable
foreach ($links as $link) { foreach ($links as $link) {
if ($link['rel'] == 'type' && $link[0] == '<http://www.w3.org/ns/ldp#NonRDFSource>') { if ($link['rel'] == 'type' && $link[0] == '<http://www.w3.org/ns/ldp#NonRDFSource>') {
$type = 'file'; $type = 'file';
@ -377,7 +383,14 @@ class FedoraAdapter implements AdapterInterface {
$return = NULL; $return = NULL;
if ($response->getStatusCode() == 410) { if ($response->getStatusCode() == 410) {
$return = FALSE; $return = FALSE;
$link_headers = Psr7\parse_header($response->getHeader('Link')); // phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$link_headers = \GuzzleHttp\Psr7\Header::parse($response->getHeader('Link'));
}
else {
$link_headers = \GuzzleHttp\Psr7\parse_header($response->getHeader('Link'));
}
// phpcs:enable
if ($link_headers) { if ($link_headers) {
$tombstones = array_filter($link_headers, function ($o) { $tombstones = array_filter($link_headers, function ($o) {
return (isset($o['rel']) && $o['rel'] == 'hasTombstone'); return (isset($o['rel']) && $o['rel'] == 'hasTombstone');

1
src/Form/ConfirmDeleteMediaAndFile.php

@ -127,7 +127,6 @@ class ConfirmDeleteMediaAndFile extends DeleteMultipleForm {
} }
// Check for files. // Check for files.
$fields = $this->entityFieldManager->getFieldDefinitions('media', $entity->bundle()); $fields = $this->entityFieldManager->getFieldDefinitions('media', $entity->bundle());
$files = [];
foreach ($fields as $field) { foreach ($fields as $field) {
$type = $field->getType(); $type = $field->getType();
if ($type == 'file' || $type == 'image') { if ($type == 'file' || $type == 'image') {

11
src/Form/IslandoraSettingsForm.php

@ -144,7 +144,7 @@ class IslandoraSettingsForm extends ConfigFormBase {
'#title' => $this->t('JWT Expiry'), '#title' => $this->t('JWT Expiry'),
'#default_value' => $config->get(self::JWT_EXPIRY), '#default_value' => $config->get(self::JWT_EXPIRY),
'#description' => $this->t('A positive time interval expression. Eg: "60 secs", "2 days", "10 hours", "7 weeks". Be sure you provide the time units (@unit), plurals are accepted.', '#description' => $this->t('A positive time interval expression. Eg: "60 secs", "2 days", "10 hours", "7 weeks". Be sure you provide the time units (@unit), plurals are accepted.',
['@unit' => implode(self::TIME_INTERVALS, ", ")] ['@unit' => implode(", ", self::TIME_INTERVALS)]
), ),
]; ];
@ -155,7 +155,12 @@ class IslandoraSettingsForm extends ConfigFormBase {
]; ];
$flysystem_config = Settings::get('flysystem'); $flysystem_config = Settings::get('flysystem');
if ($flysystem_config != NULL) {
$fedora_url = $flysystem_config['fedora']['config']['root']; $fedora_url = $flysystem_config['fedora']['config']['root'];
}
else {
$fedora_url = NULL;
}
$form[self::FEDORA_URL] = [ $form[self::FEDORA_URL] = [
'#type' => 'textfield', '#type' => 'textfield',
@ -255,11 +260,11 @@ class IslandoraSettingsForm extends ConfigFormBase {
); );
} }
else { else {
if (!preg_match("/\b(" . implode(self::TIME_INTERVALS, "|") . ")s?\b/", $expiry)) { if (!preg_match("/\b(" . implode("|", self::TIME_INTERVALS) . ")s?\b/", $expiry)) {
$form_state->setErrorByName( $form_state->setErrorByName(
self::JWT_EXPIRY, self::JWT_EXPIRY,
$this->t("No time interval found, please include one of (@int). Plurals are also accepted.", $this->t("No time interval found, please include one of (@int). Plurals are also accepted.",
['@int' => implode(self::TIME_INTERVALS, ", ")] ['@int' => implode(", ", self::TIME_INTERVALS)]
) )
); );
} }

10
src/GeminiLookup.php

@ -5,7 +5,6 @@ namespace Drupal\islandora;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\islandora\MediaSource\MediaSourceService; use Drupal\islandora\MediaSource\MediaSourceService;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use GuzzleHttp\Psr7;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Islandora\Crayfish\Commons\Client\GeminiClient; use Islandora\Crayfish\Commons\Client\GeminiClient;
@ -136,7 +135,14 @@ class GeminiLookup {
$urls['fedora'], $urls['fedora'],
['allow_redirects' => FALSE, 'headers' => ['Authorization' => $token]] ['allow_redirects' => FALSE, 'headers' => ['Authorization' => $token]]
); );
$links = Psr7\parse_header($head->getHeader("Link")); // phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Header::class)) {
$links = \GuzzleHttp\Psr7\Header::parse($head->getHeader('Link'));
}
else {
$links = \GuzzleHttp\Psr7\parse_header($head->getHeader('Link'));
}
//phpcs:enable
foreach ($links as $link) { foreach ($links as $link) {
if ($link['rel'] == 'describedby') { if ($link['rel'] == 'describedby') {
return trim($link[0], '<>'); return trim($link[0], '<>');

32
src/IslandoraUtils.php

@ -8,7 +8,6 @@ use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Entity\Query\QueryException;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
@ -48,13 +47,6 @@ class IslandoraUtils {
*/ */
protected $entityFieldManager; protected $entityFieldManager;
/**
* Entity query.
*
* @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $entityQuery;
/** /**
* Context manager. * Context manager.
* *
@ -83,8 +75,6 @@ class IslandoraUtils {
* The entity type manager. * The entity type manager.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager. * The entity field manager.
* @param \Drupal\Core\Entity\Query\QueryFactory $entity_query
* Entity query.
* @param \Drupal\context\ContextManager $context_manager * @param \Drupal\context\ContextManager $context_manager
* Context manager. * Context manager.
* @param \Drupal\flysystem\FlysystemFactory $flysystem_factory * @param \Drupal\flysystem\FlysystemFactory $flysystem_factory
@ -95,14 +85,12 @@ class IslandoraUtils {
public function __construct( public function __construct(
EntityTypeManagerInterface $entity_type_manager, EntityTypeManagerInterface $entity_type_manager,
EntityFieldManagerInterface $entity_field_manager, EntityFieldManagerInterface $entity_field_manager,
QueryFactory $entity_query,
ContextManager $context_manager, ContextManager $context_manager,
FlysystemFactory $flysystem_factory, FlysystemFactory $flysystem_factory,
LanguageManagerInterface $language_manager LanguageManagerInterface $language_manager
) { ) {
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
$this->entityFieldManager = $entity_field_manager; $this->entityFieldManager = $entity_field_manager;
$this->entityQuery = $entity_query;
$this->contextManager = $context_manager; $this->contextManager = $context_manager;
$this->flysystemFactory = $flysystem_factory; $this->flysystemFactory = $flysystem_factory;
$this->languageManager = $language_manager; $this->languageManager = $language_manager;
@ -157,7 +145,7 @@ class IslandoraUtils {
->load('media.' . self::MEDIA_OF_FIELD)) { ->load('media.' . self::MEDIA_OF_FIELD)) {
return []; return [];
} }
$mids = $this->entityQuery->get('media') $mids = $this->entityTypeManager->getStorage('media')->getQuery()
->condition(self::MEDIA_OF_FIELD, $node->id()) ->condition(self::MEDIA_OF_FIELD, $node->id())
->execute(); ->execute();
if (empty($mids)) { if (empty($mids)) {
@ -217,10 +205,12 @@ class IslandoraUtils {
); );
// Query for media that reference this file. // Query for media that reference this file.
$query = $this->entityQuery->get('media', 'OR'); $query = $this->entityTypeManager->getStorage('media')->getQuery();
$group = $query->orConditionGroup();
foreach ($conditions as $condition) { foreach ($conditions as $condition) {
$query->condition($condition, $fid); $group->condition($condition, $fid);
} }
$query->condition($group);
return $this->entityTypeManager->getStorage('media') return $this->entityTypeManager->getStorage('media')
->loadMultiple($query->execute()); ->loadMultiple($query->execute());
@ -252,7 +242,7 @@ class IslandoraUtils {
// Add field_external_uri. // Add field_external_uri.
$fields[] = self::EXTERNAL_URI_FIELD; $fields[] = self::EXTERNAL_URI_FIELD;
$query = $this->entityQuery->get('taxonomy_term'); $query = $this->entityTypeManager->getStorage('taxonomy_term')->getQuery();
$orGroup = $query->orConditionGroup(); $orGroup = $query->orConditionGroup();
foreach ($fields as $field) { foreach ($fields as $field) {
@ -504,7 +494,7 @@ class IslandoraUtils {
array_walk($term_fields, $remove_entity); array_walk($term_fields, $remove_entity);
array_walk($node_fields, $remove_entity); array_walk($node_fields, $remove_entity);
$query = $this->entityQuery->get('media'); $query = $this->entityTypeManager->getStorage('media')->getQuery();
$taxon_condition = $this->getEntityQueryOrCondition($query, $term_fields, $term->id()); $taxon_condition = $this->getEntityQueryOrCondition($query, $term_fields, $term->id());
$query->condition($taxon_condition); $query->condition($taxon_condition);
$node_condition = $this->getEntityQueryOrCondition($query, $node_fields, $node->id()); $node_condition = $this->getEntityQueryOrCondition($query, $node_fields, $node->id());
@ -531,7 +521,7 @@ class IslandoraUtils {
* Array of fields. * Array of fields.
*/ */
public function getReferencingFields($entity_type, $target_type) { public function getReferencingFields($entity_type, $target_type) {
$fields = $this->entityQuery->get('field_storage_config') $fields = $this->entityTypeManager->getStorage('field_storage_config')->getQuery()
->condition('entity_type', $entity_type) ->condition('entity_type', $entity_type)
->condition('settings.target_type', $target_type) ->condition('settings.target_type', $target_type)
->execute(); ->execute();
@ -593,11 +583,7 @@ class IslandoraUtils {
* The file URL. * The file URL.
*/ */
public function getDownloadUrl(FileInterface $file) { public function getDownloadUrl(FileInterface $file) {
$undefined = $this->languageManager->getLanguage('und'); return $file->createFileUrl(FALSE);
return $file->url('canonical', [
'absolute' => TRUE,
'language' => $undefined,
]);
} }
/** /**

14
src/MediaSource/MediaSourceService.php

@ -3,7 +3,6 @@
namespace Drupal\islandora\MediaSource; namespace Drupal\islandora\MediaSource;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
@ -43,13 +42,6 @@ class MediaSourceService {
*/ */
protected $languageManager; protected $languageManager;
/**
* Entity query.
*
* @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $entityQuery;
/** /**
* File system service. * File system service.
* *
@ -73,8 +65,6 @@ class MediaSourceService {
* The current user. * The current user.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* Language manager. * Language manager.
* @param \Drupal\Core\Entity\Query\QueryFactory $entity_query
* Entity query.
* @param \Drupal\Core\File\FileSystemInterface $file_system * @param \Drupal\Core\File\FileSystemInterface $file_system
* File system service. * File system service.
* @param \Drupal\islandora\IslandoraUtils $islandora_utils * @param \Drupal\islandora\IslandoraUtils $islandora_utils
@ -84,14 +74,12 @@ class MediaSourceService {
EntityTypeManagerInterface $entity_type_manager, EntityTypeManagerInterface $entity_type_manager,
AccountInterface $account, AccountInterface $account,
LanguageManagerInterface $language_manager, LanguageManagerInterface $language_manager,
QueryFactory $entity_query,
FileSystemInterface $file_system, FileSystemInterface $file_system,
IslandoraUtils $islandora_utils 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->fileSystem = $file_system; $this->fileSystem = $file_system;
$this->islandoraUtils = $islandora_utils; $this->islandoraUtils = $islandora_utils;
} }
@ -293,7 +281,7 @@ class MediaSourceService {
} }
$directory = $this->fileSystem->dirname($content_location); $directory = $this->fileSystem->dirname($content_location);
if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { if (!$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable"); throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable");
} }

142
src/Plugin/Action/AbstractGenerateDerivative.php

@ -3,117 +3,13 @@
namespace Drupal\islandora\Plugin\Action; namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\islandora\IslandoraUtils;
use Drupal\islandora\EventGenerator\EmitEvent;
use Drupal\islandora\EventGenerator\EventGeneratorInterface;
use Drupal\islandora\MediaSource\MediaSourceService;
use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\token\TokenInterface;
use Stomp\StatefulStomp;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Emits a Node event. * Emits a Node event.
*/ */
class AbstractGenerateDerivative extends EmitEvent { class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
/**
* Islandora utility functions.
*
* @var \Drupal\islandora\IslandoraUtils
*/
protected $utils;
/**
* Media source service.
*
* @var \Drupal\islandora\MediaSource\MediaSourceService
*/
protected $mediaSource;
/**
* Token replacement service.
*
* @var \Drupal\token\TokenInterface
*/
protected $token;
/**
* Constructs a EmitEvent action.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Session\AccountInterface $account
* Current user.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager.
* @param \Drupal\islandora\EventGenerator\EventGeneratorInterface $event_generator
* EventGenerator service to serialize AS2 events.
* @param \Stomp\StatefulStomp $stomp
* Stomp client.
* @param \Drupal\jwt\Authentication\Provider\JwtAuth $auth
* JWT Auth client.
* @param \Drupal\islandora\IslandoraUtils $utils
* Islandora utility functions.
* @param \Drupal\islandora\MediaSource\MediaSourceService $media_source
* Media source service.
* @param \Drupal\token\TokenInterface $token
* Token service.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
AccountInterface $account,
EntityTypeManagerInterface $entity_type_manager,
EventGeneratorInterface $event_generator,
StatefulStomp $stomp,
JwtAuth $auth,
IslandoraUtils $utils,
MediaSourceService $media_source,
TokenInterface $token
) {
parent::__construct(
$configuration,
$plugin_id,
$plugin_definition,
$account,
$entity_type_manager,
$event_generator,
$stomp,
$auth
);
$this->utils = $utils;
$this->mediaSource = $media_source;
$this->token = $token;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('current_user'),
$container->get('entity_type.manager'),
$container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt'),
$container->get('islandora.utils'),
$container->get('islandora.media_source_service'),
$container->get('token')
);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -127,7 +23,7 @@ class AbstractGenerateDerivative extends EmitEvent {
'mimetype' => '', 'mimetype' => '',
'args' => '', 'args' => '',
'destination_media_type' => '', 'destination_media_type' => '',
'scheme' => file_default_scheme(), 'scheme' => $this->config->get('default_scheme'),
'path' => '[date:custom:Y]-[date:custom:m]/[node:nid].bin', 'path' => '[date:custom:Y]-[date:custom:m]/[node:nid].bin',
]; ];
} }
@ -205,60 +101,60 @@ class AbstractGenerateDerivative extends EmitEvent {
$form['source_term'] = [ $form['source_term'] = [
'#type' => 'entity_autocomplete', '#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term', '#target_type' => 'taxonomy_term',
'#title' => t('Source term'), '#title' => $this->t('Source term'),
'#default_value' => $this->utils->getTermForUri($this->configuration['source_term_uri']), '#default_value' => $this->utils->getTermForUri($this->configuration['source_term_uri']),
'#required' => TRUE, '#required' => TRUE,
'#description' => t('Term indicating the source media'), '#description' => $this->t('Term indicating the source media'),
]; ];
$form['derivative_term'] = [ $form['derivative_term'] = [
'#type' => 'entity_autocomplete', '#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term', '#target_type' => 'taxonomy_term',
'#title' => t('Derivative term'), '#title' => $this->t('Derivative term'),
'#default_value' => $this->utils->getTermForUri($this->configuration['derivative_term_uri']), '#default_value' => $this->utils->getTermForUri($this->configuration['derivative_term_uri']),
'#required' => TRUE, '#required' => TRUE,
'#description' => t('Term indicating the derivative media'), '#description' => $this->t('Term indicating the derivative media'),
]; ];
$form['destination_media_type'] = [ $form['destination_media_type'] = [
'#type' => 'entity_autocomplete', '#type' => 'entity_autocomplete',
'#target_type' => 'media_type', '#target_type' => 'media_type',
'#title' => t('Derivative media type'), '#title' => $this->t('Derivative media type'),
'#default_value' => $this->getEntityById($this->configuration['destination_media_type']), '#default_value' => $this->getEntityById($this->configuration['destination_media_type']),
'#required' => TRUE, '#required' => TRUE,
'#description' => t('The Drupal media type to create with this derivative, can be different than the source'), '#description' => $this->t('The Drupal media type to create with this derivative, can be different than the source'),
]; ];
$form['mimetype'] = [ $form['mimetype'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Mimetype'), '#title' => $this->t('Mimetype'),
'#default_value' => $this->configuration['mimetype'], '#default_value' => $this->configuration['mimetype'],
'#required' => TRUE, '#required' => TRUE,
'#rows' => '8', '#rows' => '8',
'#description' => t('Mimetype to convert to (e.g. image/jpeg, video/mp4, etc...)'), '#description' => $this->t('Mimetype to convert to (e.g. image/jpeg, video/mp4, etc...)'),
]; ];
$form['args'] = [ $form['args'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Additional arguments'), '#title' => $this->t('Additional arguments'),
'#default_value' => $this->configuration['args'], '#default_value' => $this->configuration['args'],
'#rows' => '8', '#rows' => '8',
'#description' => t('Additional command line arguments'), '#description' => $this->t('Additional command line arguments'),
]; ];
$form['scheme'] = [ $form['scheme'] = [
'#type' => 'select', '#type' => 'select',
'#title' => t('File system'), '#title' => $this->t('File system'),
'#options' => $scheme_options, '#options' => $scheme_options,
'#default_value' => $this->configuration['scheme'], '#default_value' => $this->configuration['scheme'],
'#required' => TRUE, '#required' => TRUE,
]; ];
$form['path'] = [ $form['path'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('File path'), '#title' => $this->t('File path'),
'#default_value' => $this->configuration['path'], '#default_value' => $this->configuration['path'],
'#description' => t('Path within the upload destination where files will be stored. Includes the filename and optional extension.'), '#description' => $this->t('Path within the upload destination where files will be stored. Includes the filename and optional extension.'),
]; ];
$form['queue'] = [ $form['queue'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Queue name'), '#title' => $this->t('Queue name'),
'#default_value' => $this->configuration['queue'], '#default_value' => $this->configuration['queue'],
'#description' => t('Queue name to send along to help routing events, CHANGE WITH CARE. Defaults to :queue', [ '#description' => $this->t('Queue name to send along to help routing events, CHANGE WITH CARE. Defaults to :queue', [
':queue' => $this->defaultConfiguration()['queue'], ':queue' => $this->defaultConfiguration()['queue'],
]), ]),
]; ];
@ -276,14 +172,14 @@ class AbstractGenerateDerivative extends EmitEvent {
if (count($exploded_mime) != 2) { if (count($exploded_mime) != 2) {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)') $this->t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)')
); );
} }
if (empty($exploded_mime[1])) { if (empty($exploded_mime[1])) {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)') $this->t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)')
); );
} }
} }

142
src/Plugin/Action/AbstractGenerateDerivativeBase.php

@ -0,0 +1,142 @@
<?php
namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\islandora\IslandoraUtils;
use Drupal\islandora\EventGenerator\EmitEvent;
use Drupal\islandora\EventGenerator\EventGeneratorInterface;
use Drupal\islandora\MediaSource\MediaSourceService;
use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\token\TokenInterface;
use Stomp\StatefulStomp;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* A base class for constructor/creator derivative generators.
*/
class AbstractGenerateDerivativeBase extends EmitEvent {
/**
* Islandora utility functions.
*
* @var \Drupal\islandora\IslandoraUtils
*/
protected $utils;
/**
* Media source service.
*
* @var \Drupal\islandora\MediaSource\MediaSourceService
*/
protected $mediaSource;
/**
* Token replacement service.
*
* @var \Drupal\token\TokenInterface
*/
protected $token;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* The system file config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $config;
/**
* Constructs a EmitEvent action.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Session\AccountInterface $account
* Current user.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager.
* @param \Drupal\islandora\EventGenerator\EventGeneratorInterface $event_generator
* EventGenerator service to serialize AS2 events.
* @param \Stomp\StatefulStomp $stomp
* Stomp client.
* @param \Drupal\jwt\Authentication\Provider\JwtAuth $auth
* JWT Auth client.
* @param \Drupal\islandora\IslandoraUtils $utils
* Islandora utility functions.
* @param \Drupal\islandora\MediaSource\MediaSourceService $media_source
* Media source service.
* @param \Drupal\token\TokenInterface $token
* Token service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config
* The system file config.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
AccountInterface $account,
EntityTypeManagerInterface $entity_type_manager,
EventGeneratorInterface $event_generator,
StatefulStomp $stomp,
JwtAuth $auth,
IslandoraUtils $utils,
MediaSourceService $media_source,
TokenInterface $token,
MessengerInterface $messenger,
ConfigFactoryInterface $config
) {
$this->utils = $utils;
$this->mediaSource = $media_source;
$this->token = $token;
$this->messenger = $messenger;
$this->config = $config->get('system.file');
parent::__construct(
$configuration,
$plugin_id,
$plugin_definition,
$account,
$entity_type_manager,
$event_generator,
$stomp,
$auth,
$messenger
);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('current_user'),
$container->get('entity_type.manager'),
$container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt'),
$container->get('islandora.utils'),
$container->get('islandora.media_source_service'),
$container->get('token'),
$container->get('messenger'),
$container->get('config.factory')
);
}
}

140
src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

@ -2,20 +2,9 @@
namespace Drupal\islandora\Plugin\Action; namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\islandora\EventGenerator\EmitEvent;
use Drupal\islandora\EventGenerator\EventGeneratorInterface;
use Drupal\islandora\IslandoraUtils;
use Drupal\islandora\MediaSource\MediaSourceService;
use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\token\Token;
use Stomp\StatefulStomp;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Emits a Node for generating derivatives event. * Emits a Node for generating derivatives event.
@ -26,113 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* type = "media" * type = "media"
* ) * )
*/ */
class AbstractGenerateDerivativeMediaFile extends EmitEvent { class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase {
/**
* Islandora utility functions.
*
* @var \Drupal\islandora\IslandoraUtils
*/
protected $utils;
/**
* Media source service.
*
* @var \Drupal\islandora\MediaSource\MediaSourceService
*/
protected $mediaSource;
/**
* Token replacement service.
*
* @var \Drupal\token\Token
*/
protected $token;
/**
* The entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManager
*/
protected $entityFieldManager;
/**
* Constructs a EmitEvent action.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Session\AccountInterface $account
* Current user.
* @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
* Entity type manager.
* @param \Drupal\islandora\EventGenerator\EventGeneratorInterface $event_generator
* EventGenerator service to serialize AS2 events.
* @param \Stomp\StatefulStomp $stomp
* Stomp client.
* @param \Drupal\jwt\Authentication\Provider\JwtAuth $auth
* JWT Auth client.
* @param \Drupal\islandora\IslandoraUtils $utils
* Islandora utility functions.
* @param \Drupal\islandora\MediaSource\MediaSourceService $media_source
* Media source service.
* @param \Drupal\token\Token $token
* Token service.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* Field Manager service.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
AccountInterface $account,
EntityTypeManager $entity_type_manager,
EventGeneratorInterface $event_generator,
StatefulStomp $stomp,
JwtAuth $auth,
IslandoraUtils $utils,
MediaSourceService $media_source,
Token $token,
EntityFieldManagerInterface $entity_field_manager
) {
parent::__construct(
$configuration,
$plugin_id,
$plugin_definition,
$account,
$entity_type_manager,
$event_generator,
$stomp,
$auth
);
$this->utils = $utils;
$this->mediaSource = $media_source;
$this->token = $token;
$this->entityFieldManager = $entity_field_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('current_user'),
$container->get('entity_type.manager'),
$container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt'),
$container->get('islandora.utils'),
$container->get('islandora.media_source_service'),
$container->get('token'),
$container->get('entity_field.manager')
);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -222,32 +105,32 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
$form['args'] = [ $form['args'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Additional arguments'), '#title' => $this->t('Additional arguments'),
'#default_value' => $this->configuration['args'], '#default_value' => $this->configuration['args'],
'#rows' => '8', '#rows' => '8',
'#description' => t('Additional command line arguments'), '#description' => $this->t('Additional command line arguments'),
]; ];
$form['mimetype'] = [ $form['mimetype'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Mimetype'), '#title' => $this->t('Mimetype'),
'#default_value' => $this->configuration['mimetype'], '#default_value' => $this->configuration['mimetype'],
'#required' => TRUE, '#required' => TRUE,
'#rows' => '8', '#rows' => '8',
'#description' => t('Mimetype to convert to (e.g. image/jpeg, video/mp4, etc...)'), '#description' => $this->t('Mimetype to convert to (e.g. image/jpeg, video/mp4, etc...)'),
]; ];
$form['path'] = [ $form['path'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('File path'), '#title' => $this->t('File path'),
'#default_value' => $this->configuration['path'], '#default_value' => $this->configuration['path'],
'#description' => t('Path within the upload destination where files will be stored. Includes the filename and optional extension.'), '#description' => $this->t('Path within the upload destination where files will be stored. Includes the filename and optional extension.'),
]; ];
$form['queue'] = [ $form['queue'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Queue name'), '#title' => $this->t('Queue name'),
'#default_value' => $this->configuration['queue'], '#default_value' => $this->configuration['queue'],
'#description' => t('Queue name to send along to help routing events, CHANGE WITH CARE. Defaults to :queue', [ '#description' => $this->t('Queue name to send along to help routing events, CHANGE WITH CARE. Defaults to :queue', [
':queue' => $this->defaultConfiguration()['queue'], ':queue' => $this->defaultConfiguration()['queue'],
]), ]),
]; ];
@ -259,19 +142,18 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
*/ */
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state); parent::validateConfigurationForm($form, $form_state);
$mimetype = $form_state->getValue('mimetype');
$exploded = explode('/', $form_state->getValue('mimetype')); $exploded = explode('/', $form_state->getValue('mimetype'));
if (count($exploded) != 2) { if (count($exploded) != 2) {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)') $this->t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)')
); );
} }
if (empty($exploded[1])) { if (empty($exploded[1])) {
$form_state->setErrorByName( $form_state->setErrorByName(
'mimetype', 'mimetype',
t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)') $this->t('Please enter a mimetype (e.g. image/jpeg, video/mp4, audio/mp3, etc...)')
); );
} }
} }

15
src/Plugin/Action/EmitFileEvent.php

@ -5,8 +5,10 @@ namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\islandora\EventGenerator\EmitEvent; use Drupal\islandora\EventGenerator\EmitEvent;
use Drupal\islandora\EventGenerator\EventGeneratorInterface; use Drupal\islandora\EventGenerator\EventGeneratorInterface;
@ -52,6 +54,8 @@ class EmitFileEvent extends EmitEvent {
* JWT Auth client. * JWT Auth client.
* @param \Drupal\Core\File\FileSystemInterface $file_system * @param \Drupal\Core\File\FileSystemInterface $file_system
* File system service. * File system service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -62,7 +66,8 @@ class EmitFileEvent extends EmitEvent {
EventGeneratorInterface $event_generator, EventGeneratorInterface $event_generator,
StatefulStomp $stomp, StatefulStomp $stomp,
JwtAuth $auth, JwtAuth $auth,
FileSystemInterface $file_system FileSystemInterface $file_system,
MessengerInterface $messenger
) { ) {
parent::__construct( parent::__construct(
$configuration, $configuration,
@ -72,7 +77,8 @@ class EmitFileEvent extends EmitEvent {
$entity_type_manager, $entity_type_manager,
$event_generator, $event_generator,
$stomp, $stomp,
$auth $auth,
$messenger
); );
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
} }
@ -90,7 +96,8 @@ class EmitFileEvent extends EmitEvent {
$container->get('islandora.eventgenerator'), $container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'), $container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt'), $container->get('jwt.authentication.jwt'),
$container->get('file_system') $container->get('file_system'),
$container->get('messenger')
); );
} }
@ -99,7 +106,7 @@ class EmitFileEvent extends EmitEvent {
*/ */
protected function generateData(EntityInterface $entity) { protected function generateData(EntityInterface $entity) {
$uri = $entity->getFileUri(); $uri = $entity->getFileUri();
$scheme = $this->fileSystem->uriScheme($uri); $scheme = StreamWrapperManager::getScheme($uri);
$flysystem_config = Settings::get('flysystem'); $flysystem_config = Settings::get('flysystem');
$data = parent::generateData($entity); $data = parent::generateData($entity);

12
src/Plugin/Action/EmitMediaEvent.php

@ -4,6 +4,7 @@ namespace Drupal\islandora\Plugin\Action;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\jwt\Authentication\Provider\JwtAuth; use Drupal\jwt\Authentication\Provider\JwtAuth;
use Drupal\islandora\EventGenerator\EmitEvent; use Drupal\islandora\EventGenerator\EmitEvent;
@ -51,6 +52,8 @@ class EmitMediaEvent extends EmitEvent {
* JWT Auth client. * JWT Auth client.
* @param \Drupal\islandora\MediaSource\MediaSourceService $media_source * @param \Drupal\islandora\MediaSource\MediaSourceService $media_source
* Media source service. * Media source service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/ */
public function __construct( public function __construct(
array $configuration, array $configuration,
@ -61,7 +64,8 @@ class EmitMediaEvent extends EmitEvent {
EventGeneratorInterface $event_generator, EventGeneratorInterface $event_generator,
StatefulStomp $stomp, StatefulStomp $stomp,
JwtAuth $auth, JwtAuth $auth,
MediaSourceService $media_source MediaSourceService $media_source,
MessengerInterface $messenger
) { ) {
parent::__construct( parent::__construct(
$configuration, $configuration,
@ -71,7 +75,8 @@ class EmitMediaEvent extends EmitEvent {
$entity_type_manager, $entity_type_manager,
$event_generator, $event_generator,
$stomp, $stomp,
$auth $auth,
$messenger
); );
$this->mediaSource = $media_source; $this->mediaSource = $media_source;
} }
@ -89,7 +94,8 @@ class EmitMediaEvent extends EmitEvent {
$container->get('islandora.eventgenerator'), $container->get('islandora.eventgenerator'),
$container->get('islandora.stomp'), $container->get('islandora.stomp'),
$container->get('jwt.authentication.jwt'), $container->get('jwt.authentication.jwt'),
$container->get('islandora.media_source_service') $container->get('islandora.media_source_service'),
$container->get('messenger')
); );
} }

3
src/Plugin/Condition/FileUsesFilesystem.php

@ -6,6 +6,7 @@ use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
use Drupal\file\FileInterface; use Drupal\file\FileInterface;
use Drupal\islandora\IslandoraUtils; use Drupal\islandora\IslandoraUtils;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -151,7 +152,7 @@ class FileUsesFilesystem extends ConditionPluginBase implements ContainerFactory
*/ */
protected function evaluateFile(FileInterface $file) { protected function evaluateFile(FileInterface $file) {
$uri = $file->getFileUri(); $uri = $file->getFileUri();
$scheme = $this->fileSystem->uriScheme($uri); $scheme = StreamWrapperManager::getScheme($uri);
return !empty($this->configuration['filesystems'][$scheme]); return !empty($this->configuration['filesystems'][$scheme]);
} }

4
src/Plugin/Condition/MediaHasMimetype.php

@ -101,11 +101,11 @@ class MediaHasMimetype extends ConditionPluginBase implements ContainerFactoryPl
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['mimetypes'] = [ $form['mimetypes'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Mime types'), '#title' => $this->t('Mime types'),
'#default_value' => $this->configuration['mimetypes'], '#default_value' => $this->configuration['mimetypes'],
'#required' => TRUE, '#required' => TRUE,
'#maxlength' => 256, '#maxlength' => 256,
'#description' => t('Comma-delimited list of Mime types (e.g. image/jpeg, video/mp4, etc...) that trigger the condition.'), '#description' => $this->t('Comma-delimited list of Mime types (e.g. image/jpeg, video/mp4, etc...) that trigger the condition.'),
]; ];
return parent::buildConfigurationForm($form, $form_state); return parent::buildConfigurationForm($form, $form_state);
} }

2
src/Plugin/Condition/MediaSourceHasMimetype.php

@ -12,7 +12,7 @@ use Drupal\file\Entity\File;
* @Condition( * @Condition(
* id = "media_source_mimetype", * id = "media_source_mimetype",
* label = @Translation("Media Source Mimetype"), * label = @Translation("Media Source Mimetype"),
* context = { * context_definitions = {
* "media" = @ContextDefinition("entity:media", required = FALSE, label = @Translation("Media")) * "media" = @ContextDefinition("entity:media", required = FALSE, label = @Translation("Media"))
* } * }
* ) * )

4
src/Plugin/Condition/NodeHadNamespace.php

@ -95,11 +95,11 @@ class NodeHadNamespace extends ConditionPluginBase implements ContainerFactoryPl
$options = array_combine($node_fields, $node_fields); $options = array_combine($node_fields, $node_fields);
$form['pid_field'] = [ $form['pid_field'] = [
'#type' => 'select', '#type' => 'select',
'#title' => t('Field that contains the PID'), '#title' => $this->t('Field that contains the PID'),
'#options' => $options, '#options' => $options,
'#default_value' => $this->configuration['pid_field'], '#default_value' => $this->configuration['pid_field'],
'#required' => TRUE, '#required' => TRUE,
'#description' => t("Machine name of the field that contains the PID."), '#description' => $this->t("Machine name of the field that contains the PID."),
]; ];
return parent::buildConfigurationForm($form, $form_state); return parent::buildConfigurationForm($form, $form_state);

8
src/Plugin/Condition/NodeHasParent.php

@ -82,10 +82,10 @@ class NodeHasParent extends ConditionPluginBase implements ContainerFactoryPlugi
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['parent_nid'] = [ $form['parent_nid'] = [
'#type' => 'entity_autocomplete', '#type' => 'entity_autocomplete',
'#title' => t('Parent node'), '#title' => $this->t('Parent node'),
'#default_value' => $this->entityTypeManager->getStorage('node')->load($this->configuration['parent_nid']), '#default_value' => $this->entityTypeManager->getStorage('node')->load($this->configuration['parent_nid']),
'#required' => TRUE, '#required' => TRUE,
'#description' => t("Can be a collection node or a compound object."), '#description' => $this->t("Can be a collection node or a compound object."),
'#target_type' => 'node', '#target_type' => 'node',
]; ];
$field_map = \Drupal::service('entity_field.manager')->getFieldMapByFieldType('entity_reference'); $field_map = \Drupal::service('entity_field.manager')->getFieldMapByFieldType('entity_reference');
@ -93,11 +93,11 @@ class NodeHasParent extends ConditionPluginBase implements ContainerFactoryPlugi
$options = array_combine($node_fields, $node_fields); $options = array_combine($node_fields, $node_fields);
$form['parent_reference_field'] = [ $form['parent_reference_field'] = [
'#type' => 'select', '#type' => 'select',
'#title' => t('Field that contains reference to parents'), '#title' => $this->t('Field that contains reference to parents'),
'#options' => $options, '#options' => $options,
'#default_value' => $this->configuration['parent_reference_field'], '#default_value' => $this->configuration['parent_reference_field'],
'#required' => TRUE, '#required' => TRUE,
'#description' => t("Machine name of field that contains references to parent node."), '#description' => $this->t("Machine name of field that contains references to parent node."),
]; ];
return parent::buildConfigurationForm($form, $form_state); return parent::buildConfigurationForm($form, $form_state);

4
src/Plugin/Condition/NodeReferencedByNode.php

@ -85,11 +85,11 @@ class NodeReferencedByNode extends ConditionPluginBase implements ContainerFacto
$options = array_combine($node_fields, $node_fields); $options = array_combine($node_fields, $node_fields);
$form['reference_field'] = [ $form['reference_field'] = [
'#type' => 'select', '#type' => 'select',
'#title' => t('Field to check for reference to this node'), '#title' => $this->t('Field to check for reference to this node'),
'#options' => $options, '#options' => $options,
'#default_value' => $this->configuration['reference_field'], '#default_value' => $this->configuration['reference_field'],
'#required' => TRUE, '#required' => TRUE,
'#description' => t("Machine name of field that should be checked for references to this node."), '#description' => $this->t("Machine name of field that should be checked for references to this node."),
]; ];
return parent::buildConfigurationForm($form, $form_state); return parent::buildConfigurationForm($form, $form_state);

4
src/Plugin/Field/FieldFormatter/IslandoraImageFormatter.php

@ -96,7 +96,7 @@ class IslandoraImageFormatter extends ImageFormatter {
$configuration['view_mode'], $configuration['view_mode'],
$configuration['third_party_settings'], $configuration['third_party_settings'],
$container->get('current_user'), $container->get('current_user'),
$container->get('entity.manager')->getStorage('image_style'), $container->get('entity_type.manager')->getStorage('image_style'),
$container->get('islandora.utils') $container->get('islandora.utils')
); );
} }
@ -124,7 +124,7 @@ class IslandoraImageFormatter extends ImageFormatter {
return $elements; return $elements;
} }
$url = $node->urlInfo(); $url = $node->toUrl();
foreach ($elements as &$element) { foreach ($elements as &$element) {
$element['#url'] = $url; $element['#url'] = $url;

2
tests/modules/integer_weight_test_views/integer_weight_test_views.info.yml

@ -2,7 +2,7 @@ name: 'Integer weight test views'
type: module type: module
description: 'Provides default views for integer weight views tests.' description: 'Provides default views for integer weight views tests.'
package: Testing package: Testing
core: 8.x core_version_requirement: ^8 || ^9
dependencies: dependencies:
- drupal:node - drupal:node
- drupal:views - drupal:views

1
tests/modules/integer_weight_test_views/test_views/views.view.test_integer_weight.yml

@ -248,4 +248,3 @@ display:
- 'user.node_grants:view' - 'user.node_grants:view'
- user.permissions - user.permissions
tags: { } tags: { }

16
tests/src/Functional/AddMediaToNodeTest.php

@ -3,7 +3,7 @@
namespace Drupal\Tests\islandora\Functional; namespace Drupal\Tests\islandora\Functional;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
/** /**
* Tests the RelatedLinkHeader view alter. * Tests the RelatedLinkHeader view alter.
@ -94,7 +94,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
'access content', 'access content',
]); ]);
$this->drupalLogin($account); $this->drupalLogin($account);
$options['auth'] = [$account->getUsername(), $account->pass_raw]; $options['auth'] = [$account->getDisplayName(), $account->pass_raw];
$response = $client->request('PUT', $add_to_node_url, $options); $response = $client->request('PUT', $add_to_node_url, $options);
$this->assertTrue($response->getStatusCode() == 403, "Expected 403, received {$response->getStatusCode()}"); $this->assertTrue($response->getStatusCode() == 403, "Expected 403, received {$response->getStatusCode()}");
@ -108,7 +108,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
'bypass node access', 'bypass node access',
]); ]);
$this->drupalLogin($account); $this->drupalLogin($account);
$options['auth'] = [$account->getUsername(), $account->pass_raw]; $options['auth'] = [$account->getDisplayName(), $account->pass_raw];
$response = $client->request('PUT', $add_to_node_url, $options); $response = $client->request('PUT', $add_to_node_url, $options);
$this->assertTrue($response->getStatusCode() == 403, "Expected 403, received {$response->getStatusCode()}"); $this->assertTrue($response->getStatusCode() == 403, "Expected 403, received {$response->getStatusCode()}");
@ -121,7 +121,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
// Request without Content-Type header should fail with 400. // Request without Content-Type header should fail with 400.
$options = [ $options = [
'auth' => [$account->getUsername(), $account->pass_raw], 'auth' => [$account->getDisplayName(), $account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'headers' => [ 'headers' => [
'Content-Location' => 'public://test_file.txt', 'Content-Location' => 'public://test_file.txt',
@ -133,7 +133,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
// Request without Content-Location header should fail with 400. // Request without Content-Location header should fail with 400.
$options = [ $options = [
'auth' => [$account->getUsername(), $account->pass_raw], 'auth' => [$account->getDisplayName(), $account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'headers' => [ 'headers' => [
'Content-Type' => 'text/plain', 'Content-Type' => 'text/plain',
@ -145,7 +145,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
// Request without body should fail with 400. // Request without body should fail with 400.
$options = [ $options = [
'auth' => [$account->getUsername(), $account->pass_raw], 'auth' => [$account->getDisplayName(), $account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'headers' => [ 'headers' => [
'Content-Type' => 'text/plain', 'Content-Type' => 'text/plain',
@ -157,7 +157,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
// Test properly formed requests with bad parameters in the route. // Test properly formed requests with bad parameters in the route.
$options = [ $options = [
'auth' => [$account->getUsername(), $account->pass_raw], 'auth' => [$account->getDisplayName(), $account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'headers' => [ 'headers' => [
'Content-Type' => 'text/plain', 'Content-Type' => 'text/plain',
@ -200,7 +200,7 @@ class AddMediaToNodeTest extends IslandoraFunctionalTestBase {
// Should be successful with proper url, options, and permissions. // Should be successful with proper url, options, and permissions.
$options = [ $options = [
'auth' => [$account->getUsername(), $account->pass_raw], 'auth' => [$account->getDisplayName(), $account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'headers' => [ 'headers' => [
'Content-Type' => 'text/plain', 'Content-Type' => 'text/plain',

5
tests/src/Functional/ContentEntityTypeTest.php

@ -39,7 +39,7 @@ class ContentEntityTypeTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'content_entity_type'); $this->addCondition('test', 'content_entity_type');
$this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node"); $this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node");
$this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->addPresetReaction('test', 'index', 'hello_world'); $this->addPresetReaction('test', 'index', 'hello_world');
// Create a new node confirm Hello World! is printed to the screen. // Create a new node confirm Hello World! is printed to the screen.
@ -48,12 +48,11 @@ class ContentEntityTypeTest extends IslandoraFunctionalTestBase {
// Add a new media and confirm Hello World! is not printed to the // Add a new media and confirm Hello World! is not printed to the
// screen. // screen.
$file = current($this->getTestFiles('file'));
$values = [ $values = [
'name[0][value]' => 'Test Media', 'name[0][value]' => 'Test Media',
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, t('Save')); $this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save'));
$this->assertSession()->pageTextNotContains("Hello World!"); $this->assertSession()->pageTextNotContains("Hello World!");
} }

6
tests/src/Functional/DerivativeReactionTest.php

@ -52,7 +52,7 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
'field_media_of[0][target_id]' => 'Test Node', 'field_media_of[0][target_id]' => 'Test Node',
]; ];
$this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, t('Save')); $this->drupalPostForm('media/add/' . $this->testMediaType->id(), $values, $this->t('Save'));
// field_media_of is set and there's a file, so derivatives should fire. // field_media_of is set and there's a file, so derivatives should fire.
$this->assertSession()->pageTextContains("Hello World!"); $this->assertSession()->pageTextContains("Hello World!");
@ -70,9 +70,9 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file2.txt', 'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file2.txt',
]; ];
$this->drupalGet($media_url . '/edit'); $this->drupalGet($media_url . '/edit');
$this->getSession()->getPage()->pressButton(t('Remove')); $this->getSession()->getPage()->pressButton($this->t('Remove'));
$this->getSession()->getPage()->fillField('files[field_media_file_0]', __DIR__ . '/../../fixtures/test_file2.txt'); $this->getSession()->getPage()->fillField('files[field_media_file_0]', __DIR__ . '/../../fixtures/test_file2.txt');
$this->getSession()->getPage()->pressButton(t('Save')); $this->getSession()->getPage()->pressButton($this->t('Save'));
$this->assertSession()->pageTextContains("Hello World!"); $this->assertSession()->pageTextContains("Hello World!");
} }

9
tests/src/Functional/EmitNodeEventTest.php

@ -44,7 +44,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'content_entity_type'); $this->addCondition('test', 'content_entity_type');
$this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node"); $this->getSession()->getPage()->checkField("edit-conditions-content-entity-type-types-node");
$this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-content-entity-type-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->addPresetReaction('test', 'index', $action_id); $this->addPresetReaction('test', 'index', $action_id);
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
@ -68,7 +68,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
protected function createEmitAction($entity_type, $event_type) { protected function createEmitAction($entity_type, $event_type) {
$this->drupalGet('admin/config/system/actions'); $this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Emit a $entity_type event to a queue/topic"); $this->getSession()->getPage()->findById("edit-action")->selectOption("Emit a $entity_type event to a queue/topic");
$this->getSession()->getPage()->pressButton(t('Create')); $this->getSession()->getPage()->pressButton($this->t('Create'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
$action_id = "emit_" . $entity_type . "_" . lcfirst($event_type); $action_id = "emit_" . $entity_type . "_" . lcfirst($event_type);
@ -76,7 +76,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
$this->getSession()->getPage()->fillField('edit-id', $action_id); $this->getSession()->getPage()->fillField('edit-id', $action_id);
$this->getSession()->getPage()->fillField('edit-queue', "emit-$entity_type-" . lcfirst($event_type)); $this->getSession()->getPage()->fillField('edit-queue', "emit-$entity_type-" . lcfirst($event_type));
$this->getSession()->getPage()->findById("edit-event")->selectOption($event_type); $this->getSession()->getPage()->findById("edit-event")->selectOption($event_type);
$this->getSession()->getPage()->pressButton(t('Save')); $this->getSession()->getPage()->pressButton($this->t('Save'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
return $action_id; return $action_id;
@ -102,8 +102,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
"Authorization header must be set" "Authorization header must be set"
); );
$matches = []; $matches = [];
$this->assertTrue( $this->assertTrue((boolean) preg_match('/^Bearer(\s*.*)/', $headers['Authorization'], $matches),
preg_match('/^Bearer (.*)/', $headers['Authorization'], $matches),
"Authorization header must be a bearer token" "Authorization header must be a bearer token"
); );
$this->assertTrue( $this->assertTrue(

2
tests/src/Functional/EntityBundleTest.php

@ -27,7 +27,7 @@ class EntityBundleTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'islandora_entity_bundle'); $this->addCondition('test', 'islandora_entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type"); $this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->addPresetReaction('test', 'index', 'hello_world'); $this->addPresetReaction('test', 'index', 'hello_world');
// Create a new test_type confirm Hello World! is printed to the screen. // Create a new test_type confirm Hello World! is printed to the screen.

2
tests/src/Functional/FormDisplayAlterReactionTest.php

@ -49,7 +49,7 @@ class FormDisplayAlterReactionTest extends IslandoraFunctionalTestBase {
$this->drupalGet("admin/structure/context/test/reaction/add/form_display_alter"); $this->drupalGet("admin/structure/context/test/reaction/add/form_display_alter");
$this->getSession()->getPage()->findById("edit-reactions-form-display-alter-mode")->selectOption('node.secondary'); $this->getSession()->getPage()->findById("edit-reactions-form-display-alter-mode")->selectOption('node.secondary');
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
drupal_flush_all_caches(); drupal_flush_all_caches();

2
tests/src/Functional/IndexingTest.php

@ -65,7 +65,7 @@ class IndexingTest extends IslandoraFunctionalTestBase {
$this->addPresetReaction('test', 'delete', 'goodbye_world'); $this->addPresetReaction('test', 'delete', 'goodbye_world');
// Delete the node. // Delete the node.
$this->drupalPostForm("$url/delete", [], t('Delete')); $this->drupalPostForm("$url/delete", [], $this->t('Delete'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Confirm Goodbye, Cruel World! is printed to the screen. // Confirm Goodbye, Cruel World! is printed to the screen.

17
tests/src/Functional/IslandoraFunctionalTestBase.php

@ -5,6 +5,7 @@ namespace Drupal\Tests\islandora\Functional;
use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\FileStorage;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\link\LinkItemInterface; use Drupal\link\LinkItemInterface;
use Drupal\Tests\BrowserTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\field\Traits\EntityReferenceTestTrait; use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
@ -19,6 +20,7 @@ class IslandoraFunctionalTestBase extends BrowserTestBase {
use EntityReferenceTestTrait; use EntityReferenceTestTrait;
use TestFileCreationTrait; use TestFileCreationTrait;
use MediaTypeCreationTrait; use MediaTypeCreationTrait;
use StringTranslationTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -30,6 +32,11 @@ class IslandoraFunctionalTestBase extends BrowserTestBase {
'menu_link_content', 'menu_link_content',
]; ];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -275,7 +282,7 @@ EOD;
'label' => $label, 'label' => $label,
'name' => $name, 'name' => $name,
], ],
t('Save')); $this->t('Save'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -297,7 +304,7 @@ EOD;
->getPage() ->getPage()
->findById("edit-reactions-$reaction_type-actions") ->findById("edit-reactions-$reaction_type-actions")
->selectOption($action_id); ->selectOption($action_id);
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -305,7 +312,7 @@ EOD;
* Create a new node by posting its add form. * Create a new node by posting its add form.
*/ */
protected function postNodeAddForm($bundle_id, $values, $button_text) { protected function postNodeAddForm($bundle_id, $values, $button_text) {
$this->drupalPostForm("node/add/$bundle_id", $values, t('@text', ['@text' => $button_text])); $this->drupalPostForm("node/add/$bundle_id", $values, $this->t('@text', ['@text' => $button_text]));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -313,7 +320,7 @@ EOD;
* Create a new node by posting its add form. * Create a new node by posting its add form.
*/ */
protected function postTermAddForm($taxomony_id, $values, $button_text) { protected function postTermAddForm($taxomony_id, $values, $button_text) {
$this->drupalPostForm("admin/structure/taxonomy/manage/$taxomony_id/add", $values, t('@text', ['@text' => $button_text])); $this->drupalPostForm("admin/structure/taxonomy/manage/$taxomony_id/add", $values, $this->t('@text', ['@text' => $button_text]));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }
@ -321,7 +328,7 @@ EOD;
* Edits a node by posting its edit form. * Edits a node by posting its edit form.
*/ */
protected function postEntityEditForm($entity_url, $values, $button_text) { protected function postEntityEditForm($entity_url, $values, $button_text) {
$this->drupalPostForm("$entity_url/edit", $values, t('@text', ['@text' => $button_text])); $this->drupalPostForm("$entity_url/edit", $values, $this->t('@text', ['@text' => $button_text]));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
} }

6
tests/src/Functional/IslandoraImageFormatterTest.php

@ -34,7 +34,7 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
'type' => 'islandora_image', 'type' => 'islandora_image',
'settings' => ['image_style' => NULL, 'image_link' => 'content'], 'settings' => ['image_style' => NULL, 'image_link' => 'content'],
]; ];
$display = entity_get_display('media', $testImageMediaType->id(), 'default'); $display = $this->container->get('entity_display.repository')->getViewDisplay('media', $testImageMediaType->id(), 'default');
$display->setComponent('field_media_image', $display_options) $display->setComponent('field_media_image', $display_options)
->removeComponent('created') ->removeComponent('created')
->removeComponent('uid') ->removeComponent('uid')
@ -81,8 +81,8 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
$elements = $this->xpath( $elements = $this->xpath(
'//a[@href=:path]/img[@src=:url and @alt=:alt and @title=:title]', '//a[@href=:path]/img[@src=:url and @alt=:alt and @title=:title]',
[ [
':path' => $node->url(), ':path' => $node->toUrl()->toString(),
':url' => file_url_transform_relative(file_create_url($file->getFileUri())), ':url' => $file->createFileUrl(),
':alt' => 'Some Alt', ':alt' => 'Some Alt',
':title' => 'Some Title', ':title' => 'Some Title',
] ]

16
tests/src/Functional/IslandoraSettingsFormTest.php

@ -37,10 +37,10 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->assertSession()->pageTextContains("Gemini URL"); $this->assertSession()->pageTextContains("Gemini URL");
$this->assertSession()->fieldValueEquals('edit-gemini-url', ''); $this->assertSession()->fieldValueEquals('edit-gemini-url', '');
$this->drupalPostForm('admin/config/islandora/core', ['edit-gemini-url' => 'not_a_url'], t('Save configuration')); $this->drupalPostForm('admin/config/islandora/core', ['edit-gemini-url' => 'not_a_url'], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce("Cannot parse URL not_a_url"); $this->assertSession()->pageTextContainsOnce("Cannot parse URL not_a_url");
$this->drupalPostForm('admin/config/islandora/core', ['edit-gemini-url' => 'http://whaturl.bob'], t('Save configuration')); $this->drupalPostForm('admin/config/islandora/core', ['edit-gemini-url' => 'http://whaturl.bob'], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce("Cannot connect to URL http://whaturl.bob"); $this->assertSession()->pageTextContainsOnce("Cannot connect to URL http://whaturl.bob");
} }
@ -53,7 +53,7 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->drupalPostForm('admin/config/islandora/core', [ $this->drupalPostForm('admin/config/islandora/core', [
'gemini_pseudo_bundles[test_type:node]' => TRUE, 'gemini_pseudo_bundles[test_type:node]' => TRUE,
], t('Save configuration')); ], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce("Must enter Gemini URL before selecting bundles to display a pseudo field on."); $this->assertSession()->pageTextContainsOnce("Must enter Gemini URL before selecting bundles to display a pseudo field on.");
} }
@ -67,19 +67,19 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->assertSession()->pageTextContains("JWT Expiry"); $this->assertSession()->pageTextContains("JWT Expiry");
$this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour'); $this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour');
// Blank is not allowed. // Blank is not allowed.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => ""], t('Save configuration')); $this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => ""], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce('"" is not a valid time or interval expression.'); $this->assertSession()->pageTextContainsOnce('"" is not a valid time or interval expression.');
// Negative is not allowed. // Negative is not allowed.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "-2 hours"], t('Save configuration')); $this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "-2 hours"], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce('Time or interval expression cannot be negative'); $this->assertSession()->pageTextContainsOnce('Time or interval expression cannot be negative');
// Must include an integer value. // Must include an integer value.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "last hour"], t('Save configuration')); $this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "last hour"], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce('No numeric interval specified, for example "1 day"'); $this->assertSession()->pageTextContainsOnce('No numeric interval specified, for example "1 day"');
// Must have an accepted interval. // Must have an accepted interval.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "1 fortnight"], t('Save configuration')); $this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "1 fortnight"], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce('No time interval found, please include one of'); $this->assertSession()->pageTextContainsOnce('No time interval found, please include one of');
// Test a valid setting. // Test a valid setting.
$this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "2 weeks"], t('Save configuration')); $this->drupalPostForm('/admin/config/islandora/core', ['edit-jwt-expiry' => "2 weeks"], $this->t('Save configuration'));
$this->assertSession()->pageTextContainsOnce('The configuration options have been saved.'); $this->assertSession()->pageTextContainsOnce('The configuration options have been saved.');
} }

6
tests/src/Functional/JsonldSelfReferenceReactionTest.php

@ -51,7 +51,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$this->postNodeAddForm('test_type', $this->postNodeAddForm('test_type',
['title[0][value]' => 'Test Node'], ['title[0][value]' => 'Test Node'],
t('Save')); $this->t('Save'));
$this->assertSession()->pageTextContains("Test Node"); $this->assertSession()->pageTextContains("Test Node");
$url = $this->getUrl(); $url = $this->getUrl();
@ -153,8 +153,8 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$reaction_id = 'islandora_map_uri_predicate'; $reaction_id = 'islandora_map_uri_predicate';
list($file, $media) = $this->makeMediaAndFile($account); list($file, $media) = $this->makeMediaAndFile($account);
$media_url = $media->url('canonical', ['absolute' => TRUE]); $media_url = $media->toUrl('canonical', ['absolute' => TRUE])->toString();
$file_url = $file->url('canonical', ['absolute' => TRUE]); $file_url = $file->createFileUrl(FALSE);
$this->drupalGet($media_url); $this->drupalGet($media_url);
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);

10
tests/src/Functional/JsonldTypeAlterReactionTest.php

@ -27,16 +27,16 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'new_storage_type' => 'string', 'new_storage_type' => 'string',
'label' => 'Typed Predicate', 'label' => 'Typed Predicate',
'field_name' => 'type_predicate', 'field_name' => 'type_predicate',
], t('Save and continue')); ], $this->t('Save and continue'));
$this->drupalPostForm(NULL, [], t('Save field settings')); $this->drupalPostForm(NULL, [], $this->t('Save field settings'));
$this->drupalPostForm(NULL, [], t('Save settings')); $this->drupalPostForm(NULL, [], $this->t('Save settings'));
$this->assertRaw('field_type_predicate', 'Redirected to "Manage fields" page.'); $this->assertRaw('field_type_predicate', 'Redirected to "Manage fields" page.');
// Add the test node. // Add the test node.
$this->postNodeAddForm('test_type', [ $this->postNodeAddForm('test_type', [
'title[0][value]' => 'Test Node', 'title[0][value]' => 'Test Node',
'field_type_predicate[0][value]' => 'schema:Organization', 'field_type_predicate[0][value]' => 'schema:Organization',
], t('Save')); ], $this->t('Save'));
$this->assertSession()->pageTextContains("Test Node"); $this->assertSession()->pageTextContains("Test Node");
$url = $this->getUrl(); $url = $this->getUrl();
@ -73,7 +73,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
$this->addCondition('test', 'islandora_entity_bundle'); $this->addCondition('test', 'islandora_entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type"); $this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node"); $this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton($this->t('Save and continue'));
// The first time a Context is saved, you need to clear the cache. // The first time a Context is saved, you need to clear the cache.
// Subsequent changes to the context don't need a cache rebuild, though. // Subsequent changes to the context don't need a cache rebuild, though.

5
tests/src/Functional/LinkHeaderTest.php

@ -135,15 +135,14 @@ class LinkHeaderTest extends IslandoraFunctionalTestBase {
public function testMediaLinkHeaders() { public function testMediaLinkHeaders() {
// Get the file to check its url in the response headers. // Get the file to check its url in the response headers.
$file_url = $this->file->url('canonical', ['absolute' => TRUE]); $file_url = $this->file->createFileUrl(FALSE);
$rest_url = Url::fromRoute('islandora.media_source_update', ['media' => $this->media->id()]) $rest_url = Url::fromRoute('islandora.media_source_update', ['media' => $this->media->id()])
->setAbsolute() ->setAbsolute()
->toString(); ->toString();
$media_url = $this->media->url('canonical', ['absolute' => TRUE]); $media_url = $this->media->toUrl('canonical', ['absolute' => TRUE])->toString();
// Perform a GET request as anonymous. // Perform a GET request as anonymous.
$this->drupalGet($media_url, [], ['Cache-Control: no-cache']); $this->drupalGet($media_url, [], ['Cache-Control: no-cache']);
// Check link headers. // Check link headers.
$this->assertTrue( $this->assertTrue(
$this->validateLinkHeaderWithUrl('describes', $file_url, '', 'text/plain') == 1, $this->validateLinkHeaderWithUrl('describes', $file_url, '', 'text/plain') == 1,

10
tests/src/Functional/MediaSourceUpdateTest.php

@ -84,7 +84,7 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase {
// Update without Content-Type header should fail with 400. // Update without Content-Type header should fail with 400.
$options = [ $options = [
'auth' => [$this->account->getUsername(), $this->account->pass_raw], 'auth' => [$this->account->getAccountName(), $this->account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'body' => $file_contents, 'body' => $file_contents,
]; ];
@ -93,7 +93,7 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase {
// Update without body should fail with 400. // Update without body should fail with 400.
$options = [ $options = [
'auth' => [$this->account->getUsername(), $this->account->pass_raw], 'auth' => [$this->account->getAccountName(), $this->account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'headers' => [ 'headers' => [
'Content-Type' => 'text/plain', 'Content-Type' => 'text/plain',
@ -104,7 +104,7 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase {
// Should be successful. // Should be successful.
$options = [ $options = [
'auth' => [$this->account->getUsername(), $this->account->pass_raw], 'auth' => [$this->account->getAccountName(), $this->account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
'headers' => [ 'headers' => [
'Content-Type' => 'text/plain', 'Content-Type' => 'text/plain',
@ -116,10 +116,10 @@ class MediaSourceUpdateTest extends IslandoraFunctionalTestBase {
// GET the media and compare file and metadata. // GET the media and compare file and metadata.
$options = [ $options = [
'auth' => [$this->account->getUsername(), $this->account->pass_raw], 'auth' => [$this->account->getAccountName(), $this->account->pass_raw],
'http_errors' => FALSE, 'http_errors' => FALSE,
]; ];
$url = $this->media->url('canonical', ['absolute' => TRUE]); $url = $this->media->toUrl('canonical', ['absolute' => TRUE])->toString();
$response = $client->request('GET', $url . '?_format=json', $options); $response = $client->request('GET', $url . '?_format=json', $options);
$updated = json_decode($response->getBody(), TRUE); $updated = json_decode($response->getBody(), TRUE);

4
tests/src/Functional/ViewModeAlterReactionTest.php

@ -64,7 +64,7 @@ class ViewModeAlterReactionTest extends IslandoraFunctionalTestBase {
$this->drupalLogin($account); $this->drupalLogin($account);
// Stash the node's url. // Stash the node's url.
$url = $this->referencer->url('canonical', ['absolute' => TRUE]); $url = $this->referencer->toUrl('canonical', ['absolute' => TRUE]);
$this->drupalGet($url); $this->drupalGet($url);
// Make sure we're viewing the default (e.g. the media field is displayed). // Make sure we're viewing the default (e.g. the media field is displayed).
@ -75,7 +75,7 @@ class ViewModeAlterReactionTest extends IslandoraFunctionalTestBase {
$this->drupalGet("admin/structure/context/test/reaction/add/view_mode_alter"); $this->drupalGet("admin/structure/context/test/reaction/add/view_mode_alter");
$this->getSession()->getPage()->findById("edit-reactions-view-mode-alter-mode")->selectOption('node.teaser'); $this->getSession()->getPage()->findById("edit-reactions-view-mode-alter-mode")->selectOption('node.teaser');
$this->getSession()->getPage()->pressButton(t('Save and continue')); $this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
drupal_flush_all_caches(); drupal_flush_all_caches();

7
tests/src/FunctionalJavascript/IntegerWeightTest.php

@ -32,6 +32,13 @@ class IntegerWeightTest extends WebDriverTestBase {
'integer_weight_test_views', 'integer_weight_test_views',
]; ];
/**
* Name of theme.
*
* @var string
*/
protected $defaultTheme = 'stark';
/** /**
* Name of the field. * Name of the field.
* *

68
tests/src/Kernel/FedoraAdapterTest.php

@ -3,7 +3,6 @@
namespace Drupal\Tests\islandora\Kernel; namespace Drupal\Tests\islandora\Kernel;
use Drupal\islandora\Flysystem\Adapter\FedoraAdapter; use Drupal\islandora\Flysystem\Adapter\FedoraAdapter;
use GuzzleHttp\Psr7;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use Islandora\Chullo\IFedoraApi; use Islandora\Chullo\IFedoraApi;
use League\Flysystem\Config; use League\Flysystem\Config;
@ -18,6 +17,31 @@ use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
*/ */
class FedoraAdapterTest extends IslandoraKernelTestBase { class FedoraAdapterTest extends IslandoraKernelTestBase {
/**
* Shared functionality for an adapter.
*/
protected function createAdapterBase() {
$prophecy = $this->prophesize(Response::class);
$prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')
->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
// phpcs:disable
if (class_exists(\GuzzleHttp\Psr7\Utils::class)) {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\Utils::streamFor("DERP"));
} else {
$prophecy->getBody()->willReturn(\GuzzleHttp\Psr7\stream_for("DERP"));
}
// phpcs:enable
return $prophecy;
}
/** /**
* Mocks up an adapter for Fedora calls that return 404. * Mocks up an adapter for Fedora calls that return 404.
*/ */
@ -41,18 +65,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
* Mocks up an adapter for Fedora LDP-NR response. * Mocks up an adapter for Fedora LDP-NR response.
*/ */
protected function createAdapterForFile() { protected function createAdapterForFile() {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->createAdapterBase();
$prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')
->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
$prophecy->getBody()->willReturn(PSR7\stream_for("DERP"));
$response = $prophecy->reveal(); $response = $prophecy->reveal();
$prophecy = $this->prophesize(IFedoraApi::class); $prophecy = $this->prophesize(IFedoraApi::class);
@ -107,18 +120,7 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$fedora_prophecy->saveResource('', '', Argument::any()) $fedora_prophecy->saveResource('', '', Argument::any())
->willReturn($prophecy->reveal()); ->willReturn($prophecy->reveal());
$prophecy = $this->prophesize(Response::class); $prophecy = $this->createAdapterBase();
$prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')
->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
$prophecy->getBody()->willReturn(PSR7\stream_for("DERP"));
$fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal()); $fedora_prophecy->getResourceHeaders('')->willReturn($prophecy->reveal());
@ -599,18 +601,8 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
* @covers \Drupal\islandora\Flysystem\Adapter\FedoraAdapter::copy * @covers \Drupal\islandora\Flysystem\Adapter\FedoraAdapter::copy
*/ */
public function testRename() { public function testRename() {
$prophecy = $this->prophesize(Response::class); $prophecy = $this->createAdapterBase();
$prophecy->getStatusCode()->willReturn(200);
$prophecy->getHeader('Last-Modified')
->willReturn(["Wed, 25 Jul 2018 17:42:04 GMT"]);
$prophecy->getHeader('Link')
->willReturn([
'<http://www.w3.org/ns/ldp#Resource>;rel="type"',
'<http://www.w3.org/ns/ldp#NonRDFSource>;rel="type"',
]);
$prophecy->getHeader('Content-Type')->willReturn(['text/plain']);
$prophecy->getHeader('Content-Length')->willReturn([strlen("DERP")]);
$prophecy->getBody()->willReturn(PSR7\stream_for("DERP"));
$response = $prophecy->reveal(); $response = $prophecy->reveal();
$fedora_prophecy = $this->prophesize(IFedoraApi::class); $fedora_prophecy = $this->prophesize(IFedoraApi::class);
@ -620,8 +612,6 @@ class FedoraAdapterTest extends IslandoraKernelTestBase {
$prophecy->getStatusCode()->willReturn(201); $prophecy->getStatusCode()->willReturn(201);
$response = $prophecy->reveal(); $response = $prophecy->reveal();
$date = new \DateTime();
$timestamp = $date->format("D, d M Y H:i:s O");
$fedora_prophecy->createVersion('', $fedora_prophecy->createVersion('',
Argument::any(), NULL, Argument::any(), NULL,
Argument::any())->willReturn($prophecy->reveal()); Argument::any())->willReturn($prophecy->reveal());

5
tests/src/Kernel/GeminiClientFactoryTest.php

@ -8,6 +8,7 @@ use Drupal\islandora\GeminiClientFactory;
use Islandora\Crayfish\Commons\Client\GeminiClient; use Islandora\Crayfish\Commons\Client\GeminiClient;
use Prophecy\Argument; use Prophecy\Argument;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException;
/** /**
* Tests GeminiClientFactory. * Tests GeminiClientFactory.
@ -38,9 +39,9 @@ class GeminiClientFactoryTest extends IslandoraKernelTestBase {
/** /**
* @covers ::create * @covers ::create
* @expectedException \Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException
*/ */
public function testNoUrlBlank() { public function testNoUrlBlank() {
$this->expectException(PreconditionFailedHttpException::class);
$prophecy = $this->prophesize(ImmutableConfig::class); $prophecy = $this->prophesize(ImmutableConfig::class);
$prophecy->get(Argument::any())->willReturn(''); $prophecy->get(Argument::any())->willReturn('');
$immutConfig = $prophecy->reveal(); $immutConfig = $prophecy->reveal();
@ -54,9 +55,9 @@ class GeminiClientFactoryTest extends IslandoraKernelTestBase {
/** /**
* @covers ::create * @covers ::create
* @expectedException \Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException
*/ */
public function testNoUrlNull() { public function testNoUrlNull() {
$this->expectException(PreconditionFailedHttpException::class);
$prophecy = $this->prophesize(ImmutableConfig::class); $prophecy = $this->prophesize(ImmutableConfig::class);
$prophecy->get(Argument::any())->willReturn(NULL); $prophecy->get(Argument::any())->willReturn(NULL);
$immutConfig = $prophecy->reveal(); $immutConfig = $prophecy->reveal();

Loading…
Cancel
Save