Skip to content
Snippets Groups Projects

Resolve #3153851 "Phpcs standard fix"

21 files
+ 101
59
Compare changes
  • Side-by-side
  • Inline
Files
21
@@ -7,6 +7,7 @@ use Drupal\Component\Utility\Environment;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\InvokeCommand;
use Drupal\Core\Asset\LibraryDiscoveryInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountProxyInterface;
@@ -14,7 +15,6 @@ use Drupal\Core\Utility\Token;
use Drupal\dropzonejs\DropzoneJsUploadSaveInterface;
use Drupal\entity_browser\WidgetBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Asset\LibraryDiscoveryInterface;
/**
* Provides an Entity Browser widget that uploads new files.
@@ -219,7 +219,7 @@ class DropzoneJsEbWidget extends WidgetBase {
*
* @param array $form
* Form structure.
* @param FormStateInterface $form_state
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Form state object.
*
* @return \Drupal\file\FileInterface[]
@@ -227,7 +227,12 @@ class DropzoneJsEbWidget extends WidgetBase {
*/
protected function getFiles(array $form, FormStateInterface $form_state) {
$config = $this->getConfiguration();
$additional_validators = ['file_validate_size' => [Bytes::toNumber($config['settings']['max_filesize']), 0]];
$additional_validators = [
'file_validate_size' => [
Bytes::toNumber($config['settings']['max_filesize']),
0,
],
];
$files = $form_state->get(['dropzonejs', $this->uuid(), 'files']);
@@ -288,7 +293,14 @@ class DropzoneJsEbWidget extends WidgetBase {
$files = $this->getFiles($form, $form_state);
if (in_array(FALSE, $files)) {
// @todo Output the actual errors from validateFile.
$form_state->setError($form['widget']['upload'], $this->t('Some files that you are trying to upload did not pass validation. Requirements are: max file %size, allowed extensions are %extensions', ['%size' => $this->getConfiguration()['settings']['max_filesize'], '%extensions' => $this->getConfiguration()['settings']['extensions']]));
$form_state->setError($form['widget']['upload'], $this->t('Some files that you are trying to upload did not pass validation.
Requirements are: max file %size, allowed extensions are %extensions',
[
'%size' => $this->getConfiguration()['settings']['max_filesize'],
'%extensions' => $this->getConfiguration()['settings']['extensions'],
]
)
);
}
if (empty($files)) {
@@ -409,7 +421,6 @@ class DropzoneJsEbWidget extends WidgetBase {
'#default_value' => $configuration['extensions'],
];
$exif_found = $this->libraryDiscovery->getLibraryByName('dropzonejs', 'exif-js');
$form['clientside_resize'] = [
@@ -437,11 +448,11 @@ class DropzoneJsEbWidget extends WidgetBase {
'#min' => 0,
'#states' => [
'visible' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
'checked' => TRUE,
],
]
]
],
],
];
$form['resize_height'] = [
@@ -453,11 +464,11 @@ class DropzoneJsEbWidget extends WidgetBase {
'#min' => 0,
'#states' => [
'visible' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
'checked' => TRUE,
],
]
]
],
],
];
$form['resize_quality'] = [
@@ -469,11 +480,11 @@ class DropzoneJsEbWidget extends WidgetBase {
'#step' => 0.1,
'#states' => [
'visible' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
'checked' => TRUE,
],
]
]
],
],
];
$form['resize_method'] = [
@@ -486,11 +497,11 @@ class DropzoneJsEbWidget extends WidgetBase {
],
'#states' => [
'visible' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
'checked' => TRUE,
],
]
]
],
],
];
$form['thumbnail_method'] = [
@@ -503,11 +514,11 @@ class DropzoneJsEbWidget extends WidgetBase {
],
'#states' => [
'visible' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
':input[name="table[' . $this->uuid() . '][form][clientside_resize]"]' => [
'checked' => TRUE,
],
]
]
],
],
];
return $form;
@@ -608,7 +619,7 @@ class DropzoneJsEbWidget extends WidgetBase {
*/
protected function handleWidgetContext($widget_context) {
parent::handleWidgetContext($widget_context);
$validators = isset($widget_context['upload_validators']) ? $widget_context['upload_validators'] : [];
$validators = $widget_context['upload_validators'] ?? [];
if (isset($validators['file_validate_size'])) {
$this->configuration['max_filesize'] = $validators['file_validate_size'][0];
}
Loading