Skip to content

Commit

Permalink
implicit schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Stanley committed Aug 19, 2020
1 parent cbab079 commit b9fee73
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
Expand Down Expand Up @@ -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',
Expand All @@ -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'];
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit b9fee73

Please sign in to comment.