Loading audiofield.module +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ function audiofield_theme_registry_alter(&$theme_registry) { * By default, Drupal 8 does not include theme suggestions from inside the * module in which they were created, so we must add them manually here. */ $path = drupal_get_path('module', 'audiofield'); $path = \Drupal::service('extension.list.module')->getPath('audiofield'); $audioplayer_templates = drupal_find_theme_templates($theme_registry, '.html.twig', $path); foreach ($audioplayer_templates as &$audioplayer_template) { $audioplayer_template['type'] = 'module'; Loading src/AudioFieldPluginBase.php +13 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\File\FileSystemInterface; use Drupal\file\Entity\File; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\File\FileUrlGenerator; /** * Base class for audiofield plugins. Includes global functions. Loading Loading @@ -54,16 +55,24 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto */ protected $loggerFactory; /** * File URL generator service. * * @var Drupal\Core\File\FileUrlGenerator */ protected $fileUrlGenerator; /** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system) { public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system, FileUrlGenerator $file_url_generator) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->libraryDiscovery = $library_discovery; $this->messenger = $messenger; $this->loggerFactory = $logger_factory; $this->fileSystem = $file_system; $this->fileUrlGenerator = $file_url_generator; } /** Loading @@ -77,7 +86,8 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto $container->get('library.discovery'), $container->get('messenger'), $container->get('logger.factory'), $container->get('file_system') $container->get('file_system'), $container->get('file_url_generator') ); } Loading Loading @@ -460,7 +470,7 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto // Load the associated file. $file = $this->loadFileFromItem($item); // Get the file URL. return Url::fromUri(file_create_url($file->getFileUri())); return $this->fileUrlGenerator->generate($file->getFileUri()); } // Handle Link entity. elseif ($this->getClassType($item) == 'LinkItem') { Loading Loading @@ -541,7 +551,6 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto if ($this->validateEntityAgainstPlayer($item)) { // Get render information for this item. $renderInfo = $this->getAudioRenderInfo($item); // Add the file to the render array. $template_files[] = $renderInfo; Loading src/Plugin/AudioPlayer/WavesurferAudioPlayer.php +7 −5 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\File\FileUrlGenerator; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading Loading @@ -40,8 +41,8 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { /** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system, ModuleHandler $module_handler) { parent::__construct($configuration, $plugin_id, $plugin_definition, $library_discovery, $messenger, $logger_factory, $file_system); public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system, ModuleHandler $module_handler, FileUrlGenerator $file_url_generator) { parent::__construct($configuration, $plugin_id, $plugin_definition, $library_discovery, $messenger, $logger_factory, $file_system, $file_url_generator); $this->moduleHandler = $module_handler; } Loading @@ -58,7 +59,8 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { $container->get('messenger'), $container->get('logger.factory'), $container->get('file_system'), $container->get('module_handler') $container->get('module_handler'), $container->get('file_url_generator') ); } Loading Loading @@ -122,7 +124,7 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { // Get the file URL. $deliveryUrl = $file->getFileUri(); // Get the file information so we can determin extension. $deliveryFileInfo = pathinfo(file_create_url($deliveryUrl)); $deliveryFileInfo = pathinfo($this->fileUrlGenerator->generateAbsoluteString($deliveryUrl)); // Generate the URL for finding the peak file. $peakData = [ 'url' => dirname($deliveryUrl) . '/' . $deliveryFileInfo['filename'] . '.json', Loading Loading @@ -155,7 +157,7 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { // If the file exists, add it to the jQuery and template settings. if (file_exists($peakData['url'])) { $renderInfo->peakpath = $fileSettings['peakpath'] = file_create_url($peakData['url']); $renderInfo->peakpath = $fileSettings['peakpath'] = $this->fileUrlGenerator->generateAbsoluteString($peakData['url']); } } Loading Loading
audiofield.module +1 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ function audiofield_theme_registry_alter(&$theme_registry) { * By default, Drupal 8 does not include theme suggestions from inside the * module in which they were created, so we must add them manually here. */ $path = drupal_get_path('module', 'audiofield'); $path = \Drupal::service('extension.list.module')->getPath('audiofield'); $audioplayer_templates = drupal_find_theme_templates($theme_registry, '.html.twig', $path); foreach ($audioplayer_templates as &$audioplayer_template) { $audioplayer_template['type'] = 'module'; Loading
src/AudioFieldPluginBase.php +13 −4 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\File\FileSystemInterface; use Drupal\file\Entity\File; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\File\FileUrlGenerator; /** * Base class for audiofield plugins. Includes global functions. Loading Loading @@ -54,16 +55,24 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto */ protected $loggerFactory; /** * File URL generator service. * * @var Drupal\Core\File\FileUrlGenerator */ protected $fileUrlGenerator; /** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system) { public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system, FileUrlGenerator $file_url_generator) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->libraryDiscovery = $library_discovery; $this->messenger = $messenger; $this->loggerFactory = $logger_factory; $this->fileSystem = $file_system; $this->fileUrlGenerator = $file_url_generator; } /** Loading @@ -77,7 +86,8 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto $container->get('library.discovery'), $container->get('messenger'), $container->get('logger.factory'), $container->get('file_system') $container->get('file_system'), $container->get('file_url_generator') ); } Loading Loading @@ -460,7 +470,7 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto // Load the associated file. $file = $this->loadFileFromItem($item); // Get the file URL. return Url::fromUri(file_create_url($file->getFileUri())); return $this->fileUrlGenerator->generate($file->getFileUri()); } // Handle Link entity. elseif ($this->getClassType($item) == 'LinkItem') { Loading Loading @@ -541,7 +551,6 @@ abstract class AudioFieldPluginBase extends PluginBase implements ContainerFacto if ($this->validateEntityAgainstPlayer($item)) { // Get render information for this item. $renderInfo = $this->getAudioRenderInfo($item); // Add the file to the render array. $template_files[] = $renderInfo; Loading
src/Plugin/AudioPlayer/WavesurferAudioPlayer.php +7 −5 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\File\FileUrlGenerator; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading Loading @@ -40,8 +41,8 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { /** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system, ModuleHandler $module_handler) { parent::__construct($configuration, $plugin_id, $plugin_definition, $library_discovery, $messenger, $logger_factory, $file_system); public function __construct(array $configuration, $plugin_id, $plugin_definition, LibraryDiscovery $library_discovery, MessengerInterface $messenger, LoggerChannelFactoryInterface $logger_factory, FileSystemInterface $file_system, ModuleHandler $module_handler, FileUrlGenerator $file_url_generator) { parent::__construct($configuration, $plugin_id, $plugin_definition, $library_discovery, $messenger, $logger_factory, $file_system, $file_url_generator); $this->moduleHandler = $module_handler; } Loading @@ -58,7 +59,8 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { $container->get('messenger'), $container->get('logger.factory'), $container->get('file_system'), $container->get('module_handler') $container->get('module_handler'), $container->get('file_url_generator') ); } Loading Loading @@ -122,7 +124,7 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { // Get the file URL. $deliveryUrl = $file->getFileUri(); // Get the file information so we can determin extension. $deliveryFileInfo = pathinfo(file_create_url($deliveryUrl)); $deliveryFileInfo = pathinfo($this->fileUrlGenerator->generateAbsoluteString($deliveryUrl)); // Generate the URL for finding the peak file. $peakData = [ 'url' => dirname($deliveryUrl) . '/' . $deliveryFileInfo['filename'] . '.json', Loading Loading @@ -155,7 +157,7 @@ class WavesurferAudioPlayer extends AudioFieldPluginBase { // If the file exists, add it to the jQuery and template settings. if (file_exists($peakData['url'])) { $renderInfo->peakpath = $fileSettings['peakpath'] = file_create_url($peakData['url']); $renderInfo->peakpath = $fileSettings['peakpath'] = $this->fileUrlGenerator->generateAbsoluteString($peakData['url']); } } Loading