You are here

public function FlushSingleImageForm::buildForm in Flush Single Image Styles 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/FlushSingleImageForm.php, line 76

Class

FlushSingleImageForm
Class FlushSingleImageForm.

Namespace

Drupal\flush_single_image\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['path'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('File URI'),
    '#description' => $this
      ->t('The image URI to flush image styles for. This can also be a relative path in which case the ' . file_default_scheme() . ':// scheme will be used.'),
  ];
  $form['check'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Check Styles'),
  ];
  $form['check']['description'] = [
    '#markup' => '<p class="description">Click "Check Styles" to check which styles have images cached for the provided image path.</p>',
    '#prefix' => '<div id="flush-single-image-description">',
    '#suffix' => '</div>',
    '#title' => $this
      ->t('Check Styles'),
  ];
  $form['check']['submit'] = [
    '#type' => 'button',
    '#value' => $this
      ->t('Check Styles'),
    '#ajax' => [
      'callback' => '::checkStyles',
      'wrapper' => 'flush-single-image-description',
      'progress' => [
        'type' => 'throbber',
        'message' => t('Checking styles...'),
      ],
    ],
    '#attributes' => [
      'class' => [
        'form-item',
      ],
    ],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Flush'),
  ];
  return $form;
}