diff --git a/dgi_fixity.install b/dgi_fixity.install
index 2e018a5..592b891 100644
--- a/dgi_fixity.install
+++ b/dgi_fixity.install
@@ -5,8 +5,6 @@
* Install hook implementations.
*/
-use Drupal\Core\StringTranslation\TranslatableMarkup;
-
/**
* Implements hook_requirements().
*/
@@ -26,8 +24,8 @@ function dgi_fixity_requirements($phase) {
$failed = $stats['failed'] > 0;
$out_to_date = $stats['periodic']['expired'] > 0;
$requirements['dgi_fixity'] = [
- 'title' => new TranslatableMarkup('Fixity'),
- 'value' => $failed ? new TranslatableMarkup('Error') : ($out_to_date ? new TranslatableMarkup('Out of date') : new TranslatableMarkup('Up to date')),
+ 'title' => \t('Fixity'),
+ 'value' => $failed ? \t('Error') : ($out_to_date ? \t('Out of date') : \t('Up to date')),
'description' => \Drupal::service('renderer')->render($elements),
'severity' => $failed ? REQUIREMENT_ERROR : ($out_to_date ? REQUIREMENT_WARNING : REQUIREMENT_OK),
];
diff --git a/dgi_fixity.module b/dgi_fixity.module
index 1527381..07461e4 100644
--- a/dgi_fixity.module
+++ b/dgi_fixity.module
@@ -12,7 +12,6 @@ use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Mail\MailFormatHelper;
use Drupal\Core\Routing\RouteMatchInterface;
-use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\dgi_fixity\EntityTypeInfo;
use Drupal\dgi_fixity\Form\SettingsForm;
@@ -26,10 +25,10 @@ function dgi_fixity_modules_installed($modules) {
// This section is only entered when this module is installed prior to either
// of these optional dependencies installation.
// In particular the optional view:
- // - `views.view.fixity_check_source_islandora`
+ // - views.view.fixity_check_source_islandora
// Which requires the following fields:
- // - field.storage.media.field_media_use
- // - field.storage.taxonomy_term.field_external_uri
+ // - field.storage.media.field_media_use
+ // - field.storage.taxonomy_term.field_external_uri
// Which are typically provided by `islandora_core_feature`.
// All other optional configuration is for the `action` module.
if (in_array('islandora_core_feature', $modules) || in_array('action', $modules)) {
@@ -81,13 +80,13 @@ function dgi_fixity_mail($key, &$message, $params) {
}
$now = \Drupal::time()->getRequestTime();
- $subject = (new TranslatableMarkup('Fixity Check Report - @now', ['@now' => date(DATE_RFC7231, $now)]))->render();
+ $subject = \t('Fixity Check Report - @now', ['@now' => date(DATE_RFC7231, $now)])->render();
$body = $fixity->summary($stats);
if ($stats['failed'] !== 0) {
- $body[] = (new TranslatableMarkup(
+ $body[] = \t(
'There are failed checks which require your attention please review the current state of checks here.',
['@site' => Url::fromRoute('entity.fixity_check.collection', [], ['absolute' => TRUE])->toString()]
- ))->render();
+ )->render();
}
$message['subject'] = $subject;
@@ -206,7 +205,7 @@ function dgi_fixity_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.dgi_fixity':
case 'dgi_fixity.settings':
$output = array_fill(0, 2, ['#type' => 'html_tag', '#tag' => 'p']);
- $output[0]['#value'] = new TranslatableMarkup(
+ $output[0]['#value'] = \t(
'The Fixity module validates selected files by generating hashes and comparing it against stored values produced by the File Hash module for selected files uploaded to the site.',
['@file_hash' => URL::fromRoute('help.page', ['name' => 'filehash'])->toString()],
);
diff --git a/dgi_fixity.views.inc b/dgi_fixity.views.inc
index d559294..a4bef83 100644
--- a/dgi_fixity.views.inc
+++ b/dgi_fixity.views.inc
@@ -5,8 +5,6 @@
* Provide views data for file.module.
*/
-use Drupal\Core\StringTranslation\TranslatableMarkup;
-
/**
* Implements hook_views_data_alter().
*/
@@ -32,14 +30,14 @@ function dgi_fixity_views_data_alter(&$data) {
$data['file_managed'][$pseudo_field_name] = [
'real field' => $field_type->getName(),
'relationship' => [
- 'title' => new TranslatableMarkup('@entity using @field',
+ 'title' => \t('@entity using @field',
[
'@entity' => $entity_type->getLabel(),
'@field' => $field_type->getLabel(),
],
),
'label' => $group,
- 'help' => new TranslatableMarkup('Relate each @entity with a @field set to the file.',
+ 'help' => \t('Relate each @entity with a @field set to the file.',
[
'@entity' => $entity_type->getLabel(),
'@field' => $field_type->getLabel(),
diff --git a/src/Access/FixityCheckRevisionAccessCheck.php b/src/Access/FixityCheckRevisionAccessCheck.php
index 874ef76..59cf153 100644
--- a/src/Access/FixityCheckRevisionAccessCheck.php
+++ b/src/Access/FixityCheckRevisionAccessCheck.php
@@ -56,13 +56,13 @@ class FixityCheckRevisionAccessCheck implements AccessInterface {
* @param \Drupal\Core\Session\AccountInterface $account
* The currently logged in account.
* @param int $fixity_check_revision
- * (optional) The fixity_check revision ID. If not specified, but
+ * (optional) The fixity_check revision ID. If not specified, but
* $fixity_check is, access is checked for that object's revision.
* @param \Drupal\dgi_fixity\FixityCheckInterface $fixity_check
- * (optional) A fixity_check object. Used for checking access to a
+ * (optional) A fixity_check object. Used for checking access to a
* fixity_check's default revision when $fixity_check_revision is
- * unspecified. Ignored when $fixity_check_revision is specified.
- * If neither $fixity_check_revision nor $fixity_check are specified,
+ * unspecified. Ignored when $fixity_check_revision is specified.
+ * If neither $fixity_check_revision nor $fixity_check are specified,
* then access is denied.
*
* @return \Drupal\Core\Access\AccessResultInterface
@@ -97,8 +97,8 @@ class FixityCheckRevisionAccessCheck implements AccessInterface {
];
if (!$fixity_check || !isset($map[$op])) {
- // If there was no fixity_check to check against, or the $op was not one of the
- // supported ones, we return access denied.
+ // If there was no fixity_check to check against, or the $op was not one
+ // of the supported ones, we return access denied.
return FALSE;
}
@@ -122,8 +122,8 @@ class FixityCheckRevisionAccessCheck implements AccessInterface {
}
else {
// First check the access to the default revision and finally, if the
- // fixity_check passed in is not the default revision then check access to
- // that, too.
+ // fixity_check passed in is not the default revision then check access
+ // to that, too.
$this->access[$cid] = $this->accessControlHandler->access($this->storage->load($fixity_check->id()), $op, $account) && ($fixity_check->isDefaultRevision() || $this->accessControlHandler->access($fixity_check, $op, $account));
}
}
diff --git a/src/Entity/FixityCheck.php b/src/Entity/FixityCheck.php
index dac6a1c..db521da 100644
--- a/src/Entity/FixityCheck.php
+++ b/src/Entity/FixityCheck.php
@@ -8,7 +8,6 @@ use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
-use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\dgi_fixity\FixityCheckInterface;
use Drupal\file\Entity\File;
@@ -73,8 +72,8 @@ class FixityCheck extends ContentEntityBase implements FixityCheckInterface {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['file'] = BaseFieldDefinition::create('entity_reference')
- ->setLabel(new TranslatableMarkup('File'))
- ->setDescription(new TranslatableMarkup('The file entity the fixity check was performed against.'))
+ ->setLabel(\t('File'))
+ ->setDescription(\t('The file entity the fixity check was performed against.'))
->setRequired(TRUE)
->setRevisionable(FALSE)
->setTranslatable(FALSE)
@@ -89,8 +88,8 @@ class FixityCheck extends ContentEntityBase implements FixityCheckInterface {
]);
$fields['state'] = BaseFieldDefinition::create('integer')
- ->setLabel(new TranslatableMarkup('State'))
- ->setDescription(new TranslatableMarkup('A flag indicating the state of the whether the check passed or not.'))
+ ->setLabel(\t('State'))
+ ->setDescription(\t('A flag indicating the state of the whether the check passed or not.'))
->setTranslatable(FALSE)
->setRevisionable(TRUE)
->setInitialValue(static::STATE_UNDEFINED)
diff --git a/src/FixityCheckBatchCheck.php b/src/FixityCheckBatchCheck.php
index d052448..e0aa93c 100644
--- a/src/FixityCheckBatchCheck.php
+++ b/src/FixityCheckBatchCheck.php
@@ -4,7 +4,6 @@ namespace Drupal\dgi_fixity;
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
-use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\dgi_fixity\Form\SettingsForm;
/**
@@ -38,9 +37,9 @@ class FixityCheckBatchCheck {
protected static function buildFixed(array $fids, bool $force, int $batch_size) {
$builder = new BatchBuilder();
return $builder
- ->setTitle(new TranslatableMarkup('Performing checks on @count file(s)', ['@count' => count($fids)]))
- ->setInitMessage(new TranslatableMarkup('Starting'))
- ->setErrorMessage(new TranslatableMarkup('Batch has encountered an error'))
+ ->setTitle(\t('Performing checks on @count file(s)', ['@count' => count($fids)]))
+ ->setInitMessage(\t('Starting'))
+ ->setErrorMessage(\t('Batch has encountered an error'))
->addOperation([static::class, 'processFixedList'], [
$fids,
$force,
@@ -66,9 +65,9 @@ class FixityCheckBatchCheck {
);
}
return $builder
- ->setTitle(new TranslatableMarkup('Enumerating periodic checks from @count Source(s)', ['@count' => count($sources)]))
- ->setInitMessage(new TranslatableMarkup('Starting'))
- ->setErrorMessage(new TranslatableMarkup('Batch has encountered an error'))
+ ->setTitle(\t('Enumerating periodic checks from @count Source(s)', ['@count' => count($sources)]))
+ ->setInitMessage(\t('Starting'))
+ ->setErrorMessage(\t('Batch has encountered an error'))
->addOperation([static::class, 'processPeriodic'], [$force, $batch_size])
->setFinishCallback([static::class, 'finished'])
->toArray();
@@ -101,7 +100,7 @@ class FixityCheckBatchCheck {
}
$chunk = array_slice($fids, $sandbox['offset'], $batch_size);
$end = min($sandbox['total'], $sandbox['offset'] + count($chunk));
- $context['message'] = new TranslatableMarkup('Processing @start to @end of @total', [
+ $context['message'] = \t('Processing @start to @end of @total', [
'@start' => $sandbox['offset'],
'@end' => $end,
'@total' => $sandbox['total'],
@@ -139,7 +138,7 @@ class FixityCheckBatchCheck {
$check->save();
}
catch (\Exception $e) {
- $results['errors'][] = new TranslatableMarkup('Encountered an exception: @exception', [
+ $results['errors'][] = \t('Encountered an exception: @exception', [
'@exception' => $e,
]);
// In practice exceptions in this case shouldn't arise, but if they do
@@ -181,7 +180,7 @@ class FixityCheckBatchCheck {
$files = $storage->getPeriodic($sandbox['offset'], $batch_size);
$end = min($sandbox['total'], $sandbox['offset'] + count($files));
- $context['message'] = new TranslatableMarkup('Processing @start to @end', [
+ $context['message'] = \t('Processing @start to @end', [
'@start' => $sandbox['offset'],
'@end' => $end,
]);
@@ -229,7 +228,7 @@ class FixityCheckBatchCheck {
}
catch (\Exception $e) {
$results['failed']++;
- $results['errors'][] = new TranslatableMarkup('Encountered an exception: @exception', [
+ $results['errors'][] = \t('Encountered an exception: @exception', [
'@exception' => $e,
]);
}
@@ -268,7 +267,7 @@ class FixityCheckBatchCheck {
'@count was skipped.',
'@count were skipped.',
));
- $messenger->addStatus(new TranslatableMarkup(
+ $messenger->addStatus(\t(
'@count failed.', ['@count' => $results['failed']]
));
$error_count = count($results['errors']);
diff --git a/src/FixityCheckBatchGenerate.php b/src/FixityCheckBatchGenerate.php
index 1b7aa0b..0bfa5ab 100644
--- a/src/FixityCheckBatchGenerate.php
+++ b/src/FixityCheckBatchGenerate.php
@@ -4,7 +4,6 @@ namespace Drupal\dgi_fixity;
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
-use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\dgi_fixity\Form\SettingsForm;
/**
@@ -25,9 +24,9 @@ class FixityCheckBatchGenerate {
}
$builder = new BatchBuilder();
return $builder
- ->setTitle(new TranslatableMarkup('Generating Fixity Checks for previously created files'))
- ->setInitMessage(new TranslatableMarkup('Starting'))
- ->setErrorMessage(new TranslatableMarkup('Batch has encountered an error'))
+ ->setTitle(\t('Generating Fixity Checks for previously created files'))
+ ->setInitMessage(\t('Starting'))
+ ->setErrorMessage(\t('Batch has encountered an error'))
->addOperation([static::class, 'generate'], [$batch_size])
->setFinishCallback([static::class, 'finished'])
->toArray();
@@ -63,7 +62,7 @@ class FixityCheckBatchGenerate {
}
catch (\Exception $e) {
$results['failed']++;
- $results['errors'][] = new TranslatableMarkup('Encountered an exception: @exception', [
+ $results['errors'][] = \t('Encountered an exception: @exception', [
'@exception' => $e,
]);
}
@@ -99,7 +98,7 @@ class FixityCheckBatchGenerate {
'@count was successful.',
'@count were successful.',
));
- $messenger->addStatus(new TranslatableMarkup(
+ $messenger->addStatus(\t(
'@count failed.', ['@count' => $results['failed']]
));
$error_count = count($results['errors']);