Commit 36ef0ce5 authored by chr.fritsch's avatar chr.fritsch Committed by chr.fritsch

Issue #2844651 by chr.fritsch: Improve travis integration

parent cbe4f8c2
......@@ -42,7 +42,7 @@ function dropzonejs_theme() {
* An associative array containing:
* - element: A render element representing the file.
*/
function template_preprocess_dropzonejs(&$variables) {
function template_preprocess_dropzonejs(array &$variables) {
$element = $variables['element'];
$variables['attributes'] = [];
......
/**
* @file dropzone.integration.js
* @file
* dropzone.integration.js
*
* Defines the behaviors needed for dropzonejs integration.
*
* @todo Implement maxfilesexceeded.
*
*/
(function ($, Drupal, drupalSettings) {
'use strict';
......@@ -96,5 +95,4 @@
}
};
}(jQuery, Drupal, drupalSettings));
/**
* @file dropzonejs_eb_widget.common.js
* @file
* dropzonejs_eb_widget.common.js
*
* Bundles various dropzone eb widget behaviours.
*/
(function ($, Drupal, drupalSettings) {
'use strict';
......
/**
* @file dropzonejs_eb_widget.common.js
* @file
* dropzonejs_eb_widget.ief_edit.js
*
* Bundles various dropzone eb widget behaviours.
*/
(function ($, Drupal, drupalSettings) {
'use strict';
......
......@@ -98,7 +98,7 @@ class DropzoneJsEbWidget extends WidgetBase {
public function defaultConfiguration() {
return [
'upload_location' => 'public://[date:custom:Y]-[date:custom:m]',
'dropzone_description' => t('Drop files here to upload them'),
'dropzone_description' => $this->t('Drop files here to upload them'),
'max_filesize' => file_upload_max_size() / pow(Bytes::KILOBYTE, 2) . 'M',
'extensions' => 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp',
] + parent::defaultConfiguration();
......@@ -117,7 +117,7 @@ class DropzoneJsEbWidget extends WidgetBase {
}
$config = $this->getConfiguration();
$form['upload'] = [
'#title' => t('File upload'),
'#title' => $this->t('File upload'),
'#type' => 'dropzonejs',
'#required' => TRUE,
'#dropzone_description' => $config['settings']['dropzone_description'],
......@@ -206,17 +206,17 @@ class DropzoneJsEbWidget extends WidgetBase {
if ($trigger['#type'] == 'submit' && $trigger['#name'] == 'op') {
$upload_location = $this->getUploadLocation();
if (!file_prepare_directory($upload_location, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
$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']]));
$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']]));
}
$files = $this->getFiles($form, $form_state);
if (in_array(FALSE, $files)) {
// @todo Output the actual errors from validateFile.
$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']]));
$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)) {
$form_state->setError($form['widget']['upload'], t('At least one valid file should be uploaded.'));
$form_state->setError($form['widget']['upload'], $this->t('At least one valid file should be uploaded.'));
}
// If there weren't any errors set, run the normal validators.
......
......@@ -139,7 +139,7 @@ class InlineEntityFormMediaWidget extends MediaEntityDropzoneJsEbWidget {
* @return \Drupal\media_entity\MediaInterface[]
* The prepared media entities.
*/
protected function prepareEntitiesFromForm($form, FormStateInterface $form_state) {
protected function prepareEntitiesFromForm(array $form, FormStateInterface $form_state) {
$media_entities = [];
foreach (Element::children($form['widget']['entities']) as $key) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
......
......@@ -101,7 +101,7 @@ class DropzoneJsUploadSave implements DropzoneJsUploadSaveInterface {
/**
* {@inheritdoc}
*/
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, $validators = []) {
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, array $validators = []) {
// Create the file entity.
$uri = file_stream_wrapper_uri_normalize($uri);
$file_info = new \SplFileInfo($uri);
......
......@@ -35,14 +35,14 @@ interface DropzoneJsUploadSaveInterface {
* The file entity of the newly uploaded file or false in case of a failure.
* The file isn't saved yet. That should be handled by the caller.
*/
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, $validators = []);
public function createFile($uri, $destination, $extensions, AccountProxyInterface $user, array $validators = []);
/**
* Validate the uploaded file.
*
* @param \Drupal\file\FileInterface $file
* The file entity object.
* @param array $extensions
* @param string $extensions
* A space separated string of valid extensions.
* @param array $additional_validators
* An optional, associative array of callback functions used to validate the
......
......@@ -104,7 +104,7 @@ class DropzoneJs extends FormElement {
* @return array
* The $element with prepared variables ready for input.html.twig.
*/
public static function preRenderDropzoneJs($element) {
public static function preRenderDropzoneJs(array $element) {
// Convert the human size input to bytes, convert it to MB and round it.
$max_size = round(Bytes::toInt($element['#max_filesize']) / pow(Bytes::KILOBYTE, 2), 2);
......@@ -183,7 +183,7 @@ class DropzoneJs extends FormElement {
* @return string
* A space separated list of extensions.
*/
public static function getValidExtensions($element) {
public static function getValidExtensions(array $element) {
return isset($element['#extensions']) ? $element['#extensions'] : self::DEFAULT_VALID_EXTENSIONS;
}
......
......@@ -61,7 +61,7 @@ class DropzoneMediaEntityCreateEvent extends Event {
* @param array $element
* The Dropzone form element.
*/
public function __construct(MediaInterface $media_entity, FileInterface $file, $form, FormStateInterface $form_state, $element) {
public function __construct(MediaInterface $media_entity, FileInterface $file, array $form, FormStateInterface $form_state, array $element) {
$this->mediaEntity = $media_entity;
$this->file = $file;
$this->form = $form;
......@@ -145,7 +145,7 @@ class DropzoneMediaEntityCreateEvent extends Event {
* @param array $element
* The updated form element.
*/
public function setElement($element) {
public function setElement(array $element) {
$this->element = $element;
}
......
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