public function FileDeleteForm::buildForm in Panopoly 8.2
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 ContentEntityDeleteForm::buildForm
File
- modules/
panopoly/ panopoly_media/ src/ Form/ FileDeleteForm.php, line 58
Class
- FileDeleteForm
- Provides a form for deleting a file.
Namespace
Drupal\panopoly_media\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
/** @var \Drupal\file\FileInterface $file */
if ($this->fileUsage
->listUsage($this->entity)) {
$form['warning'] = [
'#theme' => 'status_messages',
// @todo Improve when https://www.drupal.org/node/2278383 lands.
'#message_list' => [
'warning' => [
$this
->t('This file has usages recorded. Deleting it may affect content that attempts to reference it.'),
],
],
'#status_headings' => [
'status' => $this
->t('Status message'),
'error' => $this
->t('Error message'),
'warning' => $this
->t('Warning message'),
],
];
}
return $form;
}