Browse Source

implicit schema

pull/756/head
Alan Stanley 5 years ago
parent
commit
b9fee7388d
  1. 16
      src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

16
src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

@ -145,7 +145,6 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
'source_term_uri' => $uri, 'source_term_uri' => $uri,
'mimetype' => '', 'mimetype' => '',
'args' => '', 'args' => '',
'scheme' => file_default_scheme(),
'path' => '[date:custom:Y]-[date:custom:m]/[media:mid].bin', 'path' => '[date:custom:Y]-[date:custom:m]/[media:mid].bin',
'source_field_name' => 'field_media_file', 'source_field_name' => 'field_media_file',
'destination_field_name' => '', 'destination_field_name' => '',
@ -177,8 +176,11 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
$token_data = [ $token_data = [
'media' => $entity, '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); $path = $this->token->replace($data['path'], $token_data);
$data['file_upload_uri'] = $data['scheme'] . '://' . $path; $data['file_upload_uri'] = $scheme . '://' . $path;
$allowed = ['queue', $allowed = ['queue',
'event', 'event',
'args', 'args',
@ -199,8 +201,6 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$schemes = $this->utils->getFilesystemSchemes();
$scheme_options = array_combine($schemes, $schemes);
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$map = $this->entityFieldManager->getFieldMapByFieldType('file'); $map = $this->entityFieldManager->getFieldMapByFieldType('file');
$file_fields = $map['media']; $file_fields = $map['media'];
@ -231,13 +231,7 @@ class AbstractGenerateDerivativeMediaFile extends EmitEvent {
'#rows' => '8', '#rows' => '8',
'#description' => t('Additional command line arguments'), '#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'] = [ $form['path'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('File path'), '#title' => t('File path'),

Loading…
Cancel
Save