Verified Commit 43d31f84 authored by Jess's avatar Jess
Browse files

Issue #2077977 by mohit_aghera, plopesc, er.pushpinderrana, nielsonm, xjm,...

Issue #2077977 by mohit_aghera, plopesc, er.pushpinderrana, nielsonm, xjm, smustgrave: Use FormBase class for the test module's form in file.module
parent 2ca89760
Loading
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -17491,18 +17491,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/file/tests/file_module_test/src/Form/FileModuleTestForm.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\file_test\\\\Form\\\\FileTestForm\\:\\:submitForm\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/file/tests/file_test/src/Form/FileTestForm.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\file_test\\\\Form\\\\FileTestForm\\:\\:validateForm\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/file/tests/file_test/src/Form/FileTestForm.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\file_test\\\\Form\\\\FileTestSaveUploadFromForm\\:\\:create\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
+2 −2
Original line number Diff line number Diff line
@@ -14,14 +14,14 @@ class FileRequiredTestForm extends FileTestForm {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
  public function getFormId(): string {
    return '_file_required_test_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
  public function buildForm(array $form, FormStateInterface $form_state): array {
    $form = parent::buildForm($form, $form_state);
    $form['file_test_upload']['#required'] = TRUE;
    return $form;
+5 −10
Original line number Diff line number Diff line
@@ -6,28 +6,28 @@

use Drupal\Core\File\FileExists;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;

/**
 * File test form class.
 */
class FileTestForm implements FormInterface {
class FileTestForm extends FormBase {
  use FileTestFormTrait;
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
  public function getFormId(): string {
    return '_file_test_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
  public function buildForm(array $form, FormStateInterface $form_state): array {

    $form = $this->baseForm($form, $form_state);

@@ -42,12 +42,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {}

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
  public function submitForm(array &$form, FormStateInterface $form_state): void {
    // Process the upload and perform validation. Note: we're using the
    // form value for the $replace parameter.
    if (!$form_state->isValueEmpty('file_subdir')) {