- Issue created by @Peter Majmesku
We do not like to execute the transliteration manually via Drush. We like to deploy it via a deploy hook. I can imagine that others do also like to deploy this via deploy or update hook. So it's part of a larger deployment and we like to save manual steps. Everything which can be automated, should be automated.
Currently the implementation in an hook is already possible. Hence the method call is a bit ugly, because the method is a bit coupled to Drush. Which is not necessary. So I am leveraging the functionality like this:
/**
* Transliterate existing files (e.g. Umlauts transformation)
*/
function my_nice_module_core_deploy_1234() {
// Install the module
$module_installer = \Drupal::service('module_installer');
$module_installer->install(['transliterate_existing_files']);
// Transliterate files with the installed module
/**
* @var \Drupal\transliterate_existing_files\TransliterateExistingFiles $tef
*/
$tef = \Drupal::service('transliterate_existing_files');
$fileStorage = \Drupal::entityTypeManager()->getStorage('file');
$fids = $fileStorage
->getQuery()
->accessCheck(FALSE)
->execute();
if (empty($fids)) {
\Drupal::messenger()->addMessage(t('No files yet.'));
return;
}
$context = [];
foreach ($fids as $fid) {
$tef::transliterateFile($fid, ['dry-run' => FALSE], $context);
}
}
It would be cleaner, if there would be a
$tef::transliterateFileFromDrush($fid, ['dry-run' => FALSE], $context);
method, so the array parameter for Drush would not be needed in $tef::transliterateFile().
Active
1.0
Code