Skip to content
This repository was archived by the owner on Jan 5, 2018. It is now read-only.

Commit 36ef0ce

Browse files
chr.fritschchrfritsch
chr.fritsch
authored andcommitted
Issue #2844651 by chr.fritsch: Improve travis integration
1 parent cbe4f8c commit 36ef0ce

10 files changed

+23
-21
lines changed

dropzonejs.module

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function dropzonejs_theme() {
4242
* An associative array containing:
4343
* - element: A render element representing the file.
4444
*/
45-
function template_preprocess_dropzonejs(&$variables) {
45+
function template_preprocess_dropzonejs(array &$variables) {
4646
$element = $variables['element'];
4747

4848
$variables['attributes'] = [];

js/dropzone.integration.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/**
2-
* @file dropzone.integration.js
2+
* @file
3+
* dropzone.integration.js
34
*
45
* Defines the behaviors needed for dropzonejs integration.
5-
*
6-
* @todo Implement maxfilesexceeded.
7-
*
86
*/
7+
98
(function ($, Drupal, drupalSettings) {
109
'use strict';
1110

@@ -96,5 +95,4 @@
9695
}
9796
};
9897

99-
10098
}(jQuery, Drupal, drupalSettings));

modules/eb_widget/js/dropzonejs_eb_widget.common.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/**
2-
* @file dropzonejs_eb_widget.common.js
2+
* @file
3+
* dropzonejs_eb_widget.common.js
34
*
45
* Bundles various dropzone eb widget behaviours.
56
*/
7+
68
(function ($, Drupal, drupalSettings) {
79
'use strict';
810

modules/eb_widget/js/dropzonejs_eb_widget.ief_edit.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/**
2-
* @file dropzonejs_eb_widget.common.js
2+
* @file
3+
* dropzonejs_eb_widget.ief_edit.js
34
*
45
* Bundles various dropzone eb widget behaviours.
56
*/
7+
68
(function ($, Drupal, drupalSettings) {
79
'use strict';
810

modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static function create(ContainerInterface $container, array $configuratio
9898
public function defaultConfiguration() {
9999
return [
100100
'upload_location' => 'public://[date:custom:Y]-[date:custom:m]',
101-
'dropzone_description' => t('Drop files here to upload them'),
101+
'dropzone_description' => $this->t('Drop files here to upload them'),
102102
'max_filesize' => file_upload_max_size() / pow(Bytes::KILOBYTE, 2) . 'M',
103103
'extensions' => 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp',
104104
] + parent::defaultConfiguration();
@@ -117,7 +117,7 @@ public function getForm(array &$original_form, FormStateInterface $form_state, a
117117
}
118118
$config = $this->getConfiguration();
119119
$form['upload'] = [
120-
'#title' => t('File upload'),
120+
'#title' => $this->t('File upload'),
121121
'#type' => 'dropzonejs',
122122
'#required' => TRUE,
123123
'#dropzone_description' => $config['settings']['dropzone_description'],
@@ -206,17 +206,17 @@ public function validate(array &$form, FormStateInterface $form_state) {
206206
if ($trigger['#type'] == 'submit' && $trigger['#name'] == 'op') {
207207
$upload_location = $this->getUploadLocation();
208208
if (!file_prepare_directory($upload_location, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
209-
$form_state->setError($form['widget']['upload'], t('Files could not be uploaded because the destination directory %destination is not configured correctly.', ['%destination' => $this->getConfiguration()['settings']['upload_location']]));
209+
$form_state->setError($form['widget']['upload'], $this->t('Files could not be uploaded because the destination directory %destination is not configured correctly.', ['%destination' => $this->getConfiguration()['settings']['upload_location']]));
210210
}
211211

212212
$files = $this->getFiles($form, $form_state);
213213
if (in_array(FALSE, $files)) {
214214
// @todo Output the actual errors from validateFile.
215-
$form_state->setError($form['widget']['upload'], 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']]));
215+
$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']]));
216216
}
217217

218218
if (empty($files)) {
219-
$form_state->setError($form['widget']['upload'], t('At least one valid file should be uploaded.'));
219+
$form_state->setError($form['widget']['upload'], $this->t('At least one valid file should be uploaded.'));
220220
}
221221

222222
// If there weren't any errors set, run the normal validators.

modules/eb_widget/src/Plugin/EntityBrowser/Widget/InlineEntityFormMediaWidget.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function validate(array &$form, FormStateInterface $form_state) {
139139
* @return \Drupal\media_entity\MediaInterface[]
140140
* The prepared media entities.
141141
*/
142-
protected function prepareEntitiesFromForm($form, FormStateInterface $form_state) {
142+
protected function prepareEntitiesFromForm(array $form, FormStateInterface $form_state) {
143143
$media_entities = [];
144144
foreach (Element::children($form['widget']['entities']) as $key) {
145145
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */

src/DropzoneJsUploadSave.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Mim
101101
/**
102102
* {@inheritdoc}
103103
*/
104-
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, $validators = []) {
104+
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, array $validators = []) {
105105
// Create the file entity.
106106
$uri = file_stream_wrapper_uri_normalize($uri);
107107
$file_info = new \SplFileInfo($uri);

src/DropzoneJsUploadSaveInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ interface DropzoneJsUploadSaveInterface {
3535
* The file entity of the newly uploaded file or false in case of a failure.
3636
* The file isn't saved yet. That should be handled by the caller.
3737
*/
38-
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, $validators = []);
38+
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, array $validators = []);
3939

4040
/**
4141
* Validate the uploaded file.
4242
*
4343
* @param \Drupal\file\FileInterface $file
4444
* The file entity object.
45-
* @param array $extensions
45+
* @param string $extensions
4646
* A space separated string of valid extensions.
4747
* @param array $additional_validators
4848
* An optional, associative array of callback functions used to validate the

src/Element/DropzoneJs.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static function processDropzoneJs(&$element, FormStateInterface $form_sta
104104
* @return array
105105
* The $element with prepared variables ready for input.html.twig.
106106
*/
107-
public static function preRenderDropzoneJs($element) {
107+
public static function preRenderDropzoneJs(array $element) {
108108
// Convert the human size input to bytes, convert it to MB and round it.
109109
$max_size = round(Bytes::toInt($element['#max_filesize']) / pow(Bytes::KILOBYTE, 2), 2);
110110

@@ -183,7 +183,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
183183
* @return string
184184
* A space separated list of extensions.
185185
*/
186-
public static function getValidExtensions($element) {
186+
public static function getValidExtensions(array $element) {
187187
return isset($element['#extensions']) ? $element['#extensions'] : self::DEFAULT_VALID_EXTENSIONS;
188188
}
189189

src/Events/DropzoneMediaEntityCreateEvent.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DropzoneMediaEntityCreateEvent extends Event {
6161
* @param array $element
6262
* The Dropzone form element.
6363
*/
64-
public function __construct(MediaInterface $media_entity, FileInterface $file, $form, FormStateInterface $form_state, $element) {
64+
public function __construct(MediaInterface $media_entity, FileInterface $file, array $form, FormStateInterface $form_state, array $element) {
6565
$this->mediaEntity = $media_entity;
6666
$this->file = $file;
6767
$this->form = $form;
@@ -145,7 +145,7 @@ public function getElement() {
145145
* @param array $element
146146
* The updated form element.
147147
*/
148-
public function setElement($element) {
148+
public function setElement(array $element) {
149149
$this->element = $element;
150150
}
151151

0 commit comments

Comments
 (0)