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

Commit 14868b7

Browse files
Milos Dencevslashrsm
authored andcommitted
Addressed feedback, some cleanup
1 parent 1c1554e commit 14868b7

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/Form/FileAddArchiveForm.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Drupal\Core\Entity\Entity;
1111
use Drupal\Core\Form\FormBase;
1212
use Drupal\Core\Form\FormStateInterface;
13-
use Drupal\Component\Utility\Bytes;
1413
use Drupal\file\Entity\File;
1514
use Drupal\file_entity\UploadValidatorsTrait;
1615

@@ -45,7 +44,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
4544
'#progress_indicator' => 'bar',
4645
'#default_value' => $form_state->has('file') ? array($form_state->get('file')->id()) : NULL,
4746
'#required' => TRUE,
48-
'#description' => $this->t('Files must be less than <strong>' . format_size($validators['file_validate_size'][0]) . '</strong><br> Allowed file types: <strong>' . $validators['file_validate_extensions'][0] . '</strong>'),
47+
'#description' => $this->t('Files must be less than <strong>%valid_size</strong><br> Allowed file types: <strong>%valid_extension</strong>', array('%valid_size' => format_size($validators['file_validate_size'][0]), '%valid_extension' => $validators['file_validate_extensions'][0])),
4948
'#upload_validators' => $validators,
5049
);
5150

@@ -73,13 +72,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
7372
return $form;
7473
}
7574

76-
/**
77-
* {@inheritdoc}
78-
*/
79-
public function validateForm(array &$form, FormStateInterface $form_state) {
80-
parent::validateForm($form, $form_state);
81-
}
82-
8375
/**
8476
* {@inheritdoc}
8577
*/
@@ -90,7 +82,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
9082
$extract_dir = file_default_scheme() . '://' . pathinfo($archive->getFilename(), PATHINFO_FILENAME);
9183
$extract_dir = file_destination($extract_dir, FILE_EXISTS_RENAME);
9284
if (!file_prepare_directory($extract_dir, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY)) {
93-
throw new \Exception(t('Unable to prepar, e directory %dir for extraction.', array('%dir' => $extract_dir)));
85+
throw new \Exception(t('Unable to prepare, the directory %dir for extraction.', array('%dir' => $extract_dir)));
9486
}
9587
$archiver->extract($extract_dir);
9688
$pattern = '/' . $form_state->getValue('pattern') . '/';
@@ -112,7 +104,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
112104
}
113105
drupal_set_message($this->t('Extracted %file and added @count new files.', array('%file' => $archive->getFilename(), '@count' => count($files))));
114106
if ($form_state->getValue('remove_archive')) {
115-
drupal_set_message($this->t('Removed archive.'));
107+
drupal_set_message($this->t('Archive %name was removed from the system.', array('%name' => $archive->getFilename())));
116108
$archive->delete();
117109
}
118110
else {

src/Form/FileAddForm.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Drupal\file_entity\Form;
99

10-
use Drupal\Component\Utility\Bytes;
1110
use Drupal\Component\Utility\SafeMarkup;
1211
use Drupal\Core\Entity\Entity\EntityFormDisplay;
1312
use Drupal\Core\Form\FormBase;

0 commit comments

Comments
 (0)