You are here

public static function FileManagement::addBackButton in File Management 8

Adds a back button with the provided text.

Parameters

array $form: The render array to where to add the back button.

string $text: The (translated) button text to use.

File

src/FileManagement.php, line 134

Class

FileManagement
File Management helper methods.

Namespace

Drupal\file_management

Code

public static function addBackButton(array &$form, $text) {
  $destination = \Drupal::request()->query
    ->get('destination');
  if (!empty($destination)) {
    $back = Link::fromTextAndUrl($text, Url::fromUserInput($destination, [
      'attributes' => [
        'class' => 'button',
      ],
    ]))
      ->toString();
    $form['back'] = [
      '#type' => 'markup',
      '#markup' => $back,
    ];
  }
}