Browse Source

properly use StringTranslationTrait

d9_islandora
Eli Zoller 4 years ago
parent
commit
bb09637449
  1. 6
      modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
  2. 6
      modules/islandora_audio/tests/src/Functional/GenerateAudioDerivativeTest.php
  3. 6
      modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
  4. 4
      modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
  5. 6
      modules/islandora_image/tests/src/Functional/GenerateImageDerivativeTest.php
  6. 4
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
  7. 6
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
  8. 6
      modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
  9. 6
      modules/islandora_video/tests/src/Functional/GenerateVideoDerivativeTest.php
  10. 28
      src/EventGenerator/EmitEvent.php
  11. 34
      src/Plugin/Action/AbstractGenerateDerivative.php
  12. 20
      src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php
  13. 4
      src/Plugin/Condition/MediaHasMimetype.php
  14. 4
      src/Plugin/Condition/NodeHadNamespace.php
  15. 8
      src/Plugin/Condition/NodeHasParent.php
  16. 4
      tests/src/Functional/ContentEntityTypeTest.php
  17. 6
      tests/src/Functional/DerivativeReactionTest.php
  18. 6
      tests/src/Functional/EmitNodeEventTest.php
  19. 2
      tests/src/Functional/EntityBundleTest.php
  20. 3
      tests/src/Functional/FormDisplayAlterReactionTest.php
  21. 1
      tests/src/Functional/GenerateDerivativeTestBase.php
  22. 2
      tests/src/Functional/IndexingTest.php
  23. 12
      tests/src/Functional/IslandoraFunctionalTestBase.php
  24. 1
      tests/src/Functional/IslandoraImageFormatterTest.php
  25. 16
      tests/src/Functional/IslandoraSettingsFormTest.php
  26. 2
      tests/src/Functional/JsonldSelfReferenceReactionTest.php
  27. 10
      tests/src/Functional/JsonldTypeAlterReactionTest.php
  28. 2
      tests/src/Functional/ViewModeAlterReactionTest.php

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) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)');
$form['args']['#description'] = t('Additional command line parameters for FFMpeg');
$form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)');
$form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
return $form;
}
@ -48,7 +48,7 @@ class GenerateAudioDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != 'audio') {
$form_state->setErrorByName(
'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.
$this->drupalGet('admin/config/system/actions');
$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->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-scheme', "public");
$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);
// 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_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 = [
'source_uri' => 'test_file.txt',

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) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = 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['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. image/jpeg, image/png, etc...)');
$form['args']['#description'] = $this->t('Additional command line arguments for ImageMagick convert (e.g. -resize 50%');
return $form;
}
@ -48,7 +48,7 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != "image") {
$form_state->setErrorByName(
'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['queue'] = 'islandora-connector-houdini';
$config['destination_media_type'] = 'file';
$config['scheme'] = file_default_scheme();
$config['scheme'] = \Drupal::config('system.file')->get('default_scheme');
return $config;
}
@ -34,7 +34,7 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
*/
public function buildConfigurationForm(array $form, FormStateInterface $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']['#type'] = 'hidden';
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.
$this->drupalGet('admin/config/system/actions');
$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->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-scheme', "public");
$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);
// 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_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 = [
'source_uri' => 'test_file.txt',

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) {
$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']['#type'] = 'textfield';
@ -50,7 +50,7 @@ class GenerateOCRDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != 'text') {
$form_state->setErrorByName(
'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['queue'] = 'islandora-connector-ocr';
$config['destination_media_type'] = 'file';
$config['scheme'] = file_default_scheme();
$config['scheme'] = \Drupal::config('system.file')->get('default_scheme');
$config['destination_text_field_name'] = '';
return $config;
}
@ -40,7 +40,7 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
$file_fields = $map['media'];
$field_options = array_combine(array_keys($file_fields), array_keys($file_fields));
$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']['#type'] = 'hidden';
$position = array_search('destination_field_name', array_keys($form));
@ -70,7 +70,7 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
if ($exploded_mime[0] != 'text') {
$form_state->setErrorByName(
'mimetype',
t('Please enter file mimetype (e.g. application/xml.)')
$this->t('Please enter file mimetype (e.g. application/xml.)')
);
}
}

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) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = t('Mimetype to convert to (e.g. video/mp4, video/quicktime, etc...)');
$form['args']['#description'] = t('Additional command line parameters for FFMpeg');
$form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. video/mp4, video/quicktime, etc...)');
$form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
return $form;
}
@ -47,7 +47,7 @@ class GenerateVideoDerivative extends AbstractGenerateDerivative {
if ($exploded_mime[0] != 'video') {
$form_state->setErrorByName(
'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.
$this->drupalGet('admin/config/system/actions');
$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->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-scheme', "public");
$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);
// 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_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 = [
'source_uri' => 'test_file.txt',

28
src/EventGenerator/EmitEvent.php

@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\jwt\Authentication\Provider\JwtAuth;
use Stomp\Exception\StompException;
use Stomp\StatefulStomp;
@ -20,6 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* Configurable action base for actions that publish messages to queues.
*/
abstract class EmitEvent extends ConfigurableActionBase implements ContainerFactoryPluginInterface {
use StringTranslationTrait;
/**
* Current user.
@ -132,10 +134,10 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
if (empty($token)) {
// JWT isn't properly configured. Log and notify user.
\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.')
);
$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;
}
@ -152,10 +154,10 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
catch (\RuntimeException $e) {
// Notify the user the event couldn't be generated and abort.
\Drupal::logger('islandora')->error(
t('Error generating event: @msg', ['@msg' => $e->getMessage()])
$this->t('Error generating event: @msg', ['@msg' => $e->getMessage()])
);
$this->messenger->addMessage(
t('Error generating event: @msg', ['@msg' => $e->getMessage()]),
$this->t('Error generating event: @msg', ['@msg' => $e->getMessage()]),
'error'
);
return;
@ -176,7 +178,7 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
// Notify user.
$this->messenger->addMessage(
t('Error publishing message: @msg',
$this->t('Error publishing message: @msg',
['@msg' => $e->getMessage()]
),
'error'
@ -207,22 +209,22 @@ abstract class EmitEvent extends ConfigurableActionBase implements ContainerFact
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['queue'] = [
'#type' => 'textfield',
'#title' => t('Queue'),
'#title' => $this->t('Queue'),
'#default_value' => $this->configuration['queue'],
'#required' => TRUE,
'#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'] = [
'#type' => 'select',
'#title' => t('Event type'),
'#title' => $this->t('Event type'),
'#default_value' => $this->configuration['event'],
'#description' => t('Type of event to emit'),
'#description' => $this->t('Type of event to emit'),
'#options' => [
'Create' => t('Create'),
'Update' => t('Update'),
'Delete' => t('Delete'),
'Generate Derivative' => t('Generate Derivative'),
'Create' => $this->t('Create'),
'Update' => $this->t('Update'),
'Delete' => $this->t('Delete'),
'Generate Derivative' => $this->t('Generate Derivative'),
],
];
return $form;

34
src/Plugin/Action/AbstractGenerateDerivative.php

@ -219,60 +219,60 @@ class AbstractGenerateDerivative extends EmitEvent {
$form['source_term'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#title' => t('Source term'),
'#title' => $this->t('Source term'),
'#default_value' => $this->utils->getTermForUri($this->configuration['source_term_uri']),
'#required' => TRUE,
'#description' => t('Term indicating the source media'),
'#description' => $this->t('Term indicating the source media'),
];
$form['derivative_term'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#title' => t('Derivative term'),
'#title' => $this->t('Derivative term'),
'#default_value' => $this->utils->getTermForUri($this->configuration['derivative_term_uri']),
'#required' => TRUE,
'#description' => t('Term indicating the derivative media'),
'#description' => $this->t('Term indicating the derivative media'),
];
$form['destination_media_type'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'media_type',
'#title' => t('Derivative media type'),
'#title' => $this->t('Derivative media type'),
'#default_value' => $this->getEntityById($this->configuration['destination_media_type']),
'#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'] = [
'#type' => 'textfield',
'#title' => t('Mimetype'),
'#title' => $this->t('Mimetype'),
'#default_value' => $this->configuration['mimetype'],
'#required' => TRUE,
'#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'] = [
'#type' => 'textfield',
'#title' => t('Additional arguments'),
'#title' => $this->t('Additional arguments'),
'#default_value' => $this->configuration['args'],
'#rows' => '8',
'#description' => t('Additional command line arguments'),
'#description' => $this->t('Additional command line arguments'),
];
$form['scheme'] = [
'#type' => 'select',
'#title' => t('File system'),
'#title' => $this->t('File system'),
'#options' => $scheme_options,
'#default_value' => $this->configuration['scheme'],
'#required' => TRUE,
];
$form['path'] = [
'#type' => 'textfield',
'#title' => t('File path'),
'#title' => $this->t('File 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'] = [
'#type' => 'textfield',
'#title' => t('Queue name'),
'#title' => $this->t('Queue name'),
'#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'],
]),
];
@ -290,14 +290,14 @@ class AbstractGenerateDerivative extends EmitEvent {
if (count($exploded_mime) != 2) {
$form_state->setErrorByName(
'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])) {
$form_state->setErrorByName(
'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...)')
);
}
}

20
src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

@ -236,32 +236,32 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
$form['args'] = [
'#type' => 'textfield',
'#title' => t('Additional arguments'),
'#title' => $this->t('Additional arguments'),
'#default_value' => $this->configuration['args'],
'#rows' => '8',
'#description' => t('Additional command line arguments'),
'#description' => $this->t('Additional command line arguments'),
];
$form['mimetype'] = [
'#type' => 'textfield',
'#title' => t('Mimetype'),
'#title' => $this->t('Mimetype'),
'#default_value' => $this->configuration['mimetype'],
'#required' => TRUE,
'#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'] = [
'#type' => 'textfield',
'#title' => t('File path'),
'#title' => $this->t('File 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'] = [
'#type' => 'textfield',
'#title' => t('Queue name'),
'#title' => $this->t('Queue name'),
'#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'],
]),
];
@ -278,14 +278,14 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
if (count($exploded) != 2) {
$form_state->setErrorByName(
'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])) {
$form_state->setErrorByName(
'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...)')
);
}
}

4
src/Plugin/Condition/MediaHasMimetype.php

@ -101,11 +101,11 @@ class MediaHasMimetype extends ConditionPluginBase implements ContainerFactoryPl
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['mimetypes'] = [
'#type' => 'textfield',
'#title' => t('Mime types'),
'#title' => $this->t('Mime types'),
'#default_value' => $this->configuration['mimetypes'],
'#required' => TRUE,
'#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);
}

4
src/Plugin/Condition/NodeHadNamespace.php

@ -95,11 +95,11 @@ class NodeHadNamespace extends ConditionPluginBase implements ContainerFactoryPl
$options = array_combine($node_fields, $node_fields);
$form['pid_field'] = [
'#type' => 'select',
'#title' => t('Field that contains the PID'),
'#title' => $this->t('Field that contains the PID'),
'#options' => $options,
'#default_value' => $this->configuration['pid_field'],
'#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);

8
src/Plugin/Condition/NodeHasParent.php

@ -82,10 +82,10 @@ class NodeHasParent extends ConditionPluginBase implements ContainerFactoryPlugi
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['parent_nid'] = [
'#type' => 'entity_autocomplete',
'#title' => t('Parent node'),
'#title' => $this->t('Parent node'),
'#default_value' => $this->entityTypeManager->getStorage('node')->load($this->configuration['parent_nid']),
'#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',
];
$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);
$form['parent_reference_field'] = [
'#type' => 'select',
'#title' => t('Field that contains reference to parents'),
'#title' => $this->('Field that contains reference to parents'),
'#options' => $options,
'#default_value' => $this->configuration['parent_reference_field'],
'#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);

4
tests/src/Functional/ContentEntityTypeTest.php

@ -39,7 +39,7 @@ class ContentEntityTypeTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'content_entity_type');
$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()->pressButton(t('Save and continue'));
$this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->addPresetReaction('test', 'index', 'hello_world');
// Create a new node confirm Hello World! is printed to the screen.
@ -53,7 +53,7 @@ class ContentEntityTypeTest extends IslandoraFunctionalTestBase {
'name[0][value]' => 'Test Media',
'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!");
}

6
tests/src/Functional/DerivativeReactionTest.php

@ -52,7 +52,7 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
'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.
$this->assertSession()->pageTextContains("Hello World!");
@ -70,9 +70,9 @@ class DerivativeReactionTest extends IslandoraFunctionalTestBase {
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file2.txt',
];
$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()->pressButton(t('Save'));
$this->getSession()->getPage()->pressButton($this->t('Save'));
$this->assertSession()->pageTextContains("Hello World!");
}

6
tests/src/Functional/EmitNodeEventTest.php

@ -44,7 +44,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'content_entity_type');
$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()->pressButton(t('Save and continue'));
$this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->addPresetReaction('test', 'index', $action_id);
$this->assertSession()->statusCodeEquals(200);
@ -68,7 +68,7 @@ class EmitNodeEventTest extends IslandoraFunctionalTestBase {
protected function createEmitAction($entity_type, $event_type) {
$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()->pressButton(t('Create'));
$this->getSession()->getPage()->pressButton($this->t('Create'));
$this->assertSession()->statusCodeEquals(200);
$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-queue', "emit-$entity_type-" . lcfirst($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);
return $action_id;

2
tests/src/Functional/EntityBundleTest.php

@ -27,7 +27,7 @@ class EntityBundleTest extends IslandoraFunctionalTestBase {
$this->addCondition('test', 'islandora_entity_bundle');
$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()->pressButton(t('Save and continue'));
$this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->addPresetReaction('test', 'index', 'hello_world');
// Create a new test_type confirm Hello World! is printed to the screen.

3
tests/src/Functional/FormDisplayAlterReactionTest.php

@ -8,7 +8,6 @@ namespace Drupal\Tests\islandora\Functional;
* @group islandora
*/
class FormDisplayAlterReactionTest extends IslandoraFunctionalTestBase {
/**
* @covers \Drupal\islandora\Plugin\ContextReaction\FormDisplayAlterReaction::execute
* @covers \Drupal\islandora\Plugin\ContextReaction\FormDisplayAlterReaction::buildConfigurationForm
@ -49,7 +48,7 @@ class FormDisplayAlterReactionTest extends IslandoraFunctionalTestBase {
$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()->pressButton(t('Save and continue'));
$this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->assertSession()->statusCodeEquals(200);
drupal_flush_all_caches();

1
tests/src/Functional/GenerateDerivativeTestBase.php

@ -2,6 +2,7 @@
namespace Drupal\Tests\islandora\Functional;
/**
* Tests the GenerateDerivative action.
*/

2
tests/src/Functional/IndexingTest.php

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

12
tests/src/Functional/IslandoraFunctionalTestBase.php

@ -5,6 +5,7 @@ namespace Drupal\Tests\islandora\Functional;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\link\LinkItemInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
@ -19,6 +20,7 @@ class IslandoraFunctionalTestBase extends BrowserTestBase {
use EntityReferenceTestTrait;
use TestFileCreationTrait;
use MediaTypeCreationTrait;
use StringTranslationTrait;
/**
* {@inheritdoc}
@ -275,7 +277,7 @@ EOD;
'label' => $label,
'name' => $name,
],
t('Save'));
$this->t('Save'));
$this->assertSession()->statusCodeEquals(200);
}
@ -297,7 +299,7 @@ EOD;
->getPage()
->findById("edit-reactions-$reaction_type-actions")
->selectOption($action_id);
$this->getSession()->getPage()->pressButton(t('Save and continue'));
$this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->assertSession()->statusCodeEquals(200);
}
@ -305,7 +307,7 @@ EOD;
* Create a new node by posting its add form.
*/
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);
}
@ -313,7 +315,7 @@ EOD;
* Create a new node by posting its add form.
*/
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);
}
@ -321,7 +323,7 @@ EOD;
* Edits a node by posting its edit form.
*/
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);
}

1
tests/src/Functional/IslandoraImageFormatterTest.php

@ -78,7 +78,6 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
// Assert that the image is rendered into html as a link pointing
// to the Node, not the Media (that's what the islandora_image
// formatter does).
$elements = $this->xpath(
'//a[@href=:path]/img[@src=:url and @alt=:alt and @title=:title]',
[

16
tests/src/Functional/IslandoraSettingsFormTest.php

@ -37,10 +37,10 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->assertSession()->pageTextContains("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->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");
}
@ -53,7 +53,7 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->drupalPostForm('admin/config/islandora/core', [
'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.");
}
@ -67,19 +67,19 @@ class IslandoraSettingsFormTest extends IslandoraFunctionalTestBase {
$this->assertSession()->pageTextContains("JWT Expiry");
$this->assertSession()->fieldValueEquals('edit-jwt-expiry', '+2 hour');
// 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.');
// 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');
// 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"');
// 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');
// 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.');
}

2
tests/src/Functional/JsonldSelfReferenceReactionTest.php

@ -51,7 +51,7 @@ class JsonldSelfReferenceReactionTest extends IslandoraFunctionalTestBase {
$this->postNodeAddForm('test_type',
['title[0][value]' => 'Test Node'],
t('Save'));
$this->t('Save'));
$this->assertSession()->pageTextContains("Test Node");
$url = $this->getUrl();

10
tests/src/Functional/JsonldTypeAlterReactionTest.php

@ -27,16 +27,16 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
'new_storage_type' => 'string',
'label' => 'Typed Predicate',
'field_name' => 'type_predicate',
], t('Save and continue'));
$this->drupalPostForm(NULL, [], t('Save field settings'));
$this->drupalPostForm(NULL, [], t('Save settings'));
], $this->t('Save and continue'));
$this->drupalPostForm(NULL, [], $this->t('Save field settings'));
$this->drupalPostForm(NULL, [], $this->t('Save settings'));
$this->assertRaw('field_type_predicate', 'Redirected to "Manage fields" page.');
// Add the test node.
$this->postNodeAddForm('test_type', [
'title[0][value]' => 'Test Node',
'field_type_predicate[0][value]' => 'schema:Organization',
], t('Save'));
], $this->t('Save'));
$this->assertSession()->pageTextContains("Test Node");
$url = $this->getUrl();
@ -73,7 +73,7 @@ class JsonldTypeAlterReactionTest extends JsonldSelfReferenceReactionTest {
$this->addCondition('test', 'islandora_entity_bundle');
$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()->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.
// Subsequent changes to the context don't need a cache rebuild, though.

2
tests/src/Functional/ViewModeAlterReactionTest.php

@ -75,7 +75,7 @@ class ViewModeAlterReactionTest extends IslandoraFunctionalTestBase {
$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()->pressButton(t('Save and continue'));
$this->getSession()->getPage()->pressButton($this->t('Save and continue'));
$this->assertSession()->statusCodeEquals(200);
drupal_flush_all_caches();

Loading…
Cancel
Save