MediaThumbnailRefreshForm.php in Media Thumbnails 8
File
src/Form/MediaThumbnailRefreshForm.php
View source
<?php
namespace Drupal\media_thumbnails\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\media_thumbnails\Batch\RefreshBatch;
class MediaThumbnailRefreshForm extends ConfirmFormBase {
public function getFormId() : string {
return 'media_thumbnails_refresh_form';
}
public function getQuestion() : string {
return $this
->t('Refresh the thumbnails for all media entities?');
}
public function getDescription() : string {
return $this
->t('Are you sure you want to refresh the thumbnails for all media entities? Thumbnails for @count entities will be refreshed.', [
'@count' => number_format(RefreshBatch::count()),
]);
}
public function getConfirmText() : string {
return $this
->t('Refresh');
}
public function getCancelUrl() : Url {
return new Url('media_thumbnails.admin');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
batch_set(RefreshBatch::createBatch());
}
}