Commit 17fe1dd7 authored by jungle's avatar jungle

Issue #2808687 by paranojik, mtodor, samuel.mortenson, a.milkovsky, joachim,...

Issue #2808687 by paranojik, mtodor, samuel.mortenson, a.milkovsky, joachim, Primsi, chr.fritsch, stefanos.petrakis, imclean, Tahanima, ñull, jungle, slashrsm, juanramonperez: Use reusable settings defined on field level rather than duplicating configuration
parent 8cba97bb
......@@ -603,4 +603,18 @@ class DropzoneJsEbWidget extends WidgetBase {
return $ajax;
}
/**
* {@inheritdoc}
*/
protected function handleWidgetContext($widget_context) {
parent::handleWidgetContext($widget_context);
$validators = isset($widget_context['upload_validators']) ? $widget_context['upload_validators'] : [];
if (isset($validators['file_validate_size'])) {
$this->configuration['max_filesize'] = $validators['file_validate_size'][0];
}
if (isset($validators['file_validate_extensions'])) {
$this->configuration['extensions'] = $validators['file_validate_extensions'][0];
}
}
}
......@@ -104,6 +104,11 @@ class MediaEntityDropzoneJsEbWidget extends DropzoneJsEbWidget {
]);
}
// Remove these config options as these are propagated from the field.
$form['max_filesize']['#access'] = FALSE;
$form['extensions']['#access'] = FALSE;
$form['upload_location']['#access'] = FALSE;
return $form;
}
......@@ -167,4 +172,18 @@ class MediaEntityDropzoneJsEbWidget extends DropzoneJsEbWidget {
$this->clearFormValues($element, $form_state);
}
/**
* {@inheritdoc}
*/
protected function handleWidgetContext($widget_context) {
parent::handleWidgetContext($widget_context);
$bundle = $this->getType();
$source = $bundle->getSource();
$field = $source->getSourceFieldDefinition($bundle);
$field_storage = $field->getFieldStorageDefinition();
$this->configuration['upload_location'] = $field_storage->getSettings()['uri_scheme'] . '://' . $field->getSettings()['file_directory'];
$this->configuration['max_filesize'] = $field->getSettings()['max_filesize'];
$this->configuration['extensions'] = $field->getSettings()['file_extensions'];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment