From b9fee7388dcb8b32f1000d7cec909c6c6bb96dcf Mon Sep 17 00:00:00 2001 From: Alan Stanley Date: Wed, 19 Aug 2020 14:28:03 +0000 Subject: [PATCH] implicit schema --- .../AbstractGenerateDerivativeMediaFile.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php b/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php index 9b20eb1e9..329bd25b5 100644 --- a/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php +++ b/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php @@ -145,7 +145,6 @@ public function defaultConfiguration() { 'source_term_uri' => $uri, 'mimetype' => '', 'args' => '', - 'scheme' => file_default_scheme(), 'path' => '[date:custom:Y]-[date:custom:m]/[media:mid].bin', 'source_field_name' => 'field_media_file', 'destination_field_name' => '', @@ -177,8 +176,11 @@ protected function generateData(EntityInterface $entity) { $token_data = [ 'media' => $entity, ]; + $destination_field = $this->configuration['destination_field_name']; + $field = \Drupal::entityTypeManager()->getStorage('field_storage_config')->load("media.$destination_field"); + $scheme = $field->getSetting('uri_scheme'); $path = $this->token->replace($data['path'], $token_data); - $data['file_upload_uri'] = $data['scheme'] . '://' . $path; + $data['file_upload_uri'] = $scheme . '://' . $path; $allowed = ['queue', 'event', 'args', @@ -199,8 +201,6 @@ protected function generateData(EntityInterface $entity) { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $schemes = $this->utils->getFilesystemSchemes(); - $scheme_options = array_combine($schemes, $schemes); $form = parent::buildConfigurationForm($form, $form_state); $map = $this->entityFieldManager->getFieldMapByFieldType('file'); $file_fields = $map['media']; @@ -231,13 +231,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#rows' => '8', '#description' => t('Additional command line arguments'), ]; - $form['scheme'] = [ - '#type' => 'select', - '#title' => t('File system'), - '#options' => $scheme_options, - '#default_value' => $this->configuration['scheme'], - '#required' => TRUE, - ]; + $form['path'] = [ '#type' => 'textfield', '#title' => t('File path'),