From ea2236ab3139b72e70ece1b0dd5fb8a3e4e20ed5 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Thu, 23 May 2019 16:30:48 -0300 Subject: [PATCH] Forcing flysystem downloads to be language neutral (#137) * Forcing flysystem downloads to be language neutral * Coder.... --- src/Flysystem/Fedora.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Flysystem/Fedora.php b/src/Flysystem/Fedora.php index fadd8a0f..fd347b89 100644 --- a/src/Flysystem/Fedora.php +++ b/src/Flysystem/Fedora.php @@ -4,6 +4,7 @@ namespace Drupal\islandora\Flysystem; use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Url; use Drupal\flysystem\Plugin\FlysystemPluginInterface; use Drupal\flysystem\Plugin\FlysystemUrlTrait; use Drupal\islandora\Flysystem\Adapter\FedoraAdapter; @@ -116,4 +117,24 @@ class Fedora implements FlysystemPluginInterface, ContainerFactoryPluginInterfac return []; } + /** + * {@inheritdoc} + */ + public function getExternalUrl($uri) { + $path = str_replace('\\', '/', $this->getTarget($uri)); + + $arguments = [ + 'scheme' => $this->getScheme($uri), + 'filepath' => $path, + ]; + + // Force file urls to be language neutral. + $undefined = \Drupal::languageManager()->getLanguage('und'); + return Url::fromRoute( + 'flysystem.serve', + $arguments, + ['absolute' => TRUE, 'language' => $undefined] + )->toString(); + } + }