You are here

public function UpdateScriptTestController::databaseUpdatesMenuItem in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php \Drupal\update_script_test\Controller\UpdateScriptTestController::databaseUpdatesMenuItem()
  2. 9 core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php \Drupal\update_script_test\Controller\UpdateScriptTestController::databaseUpdatesMenuItem()

Outputs a link to the database updates URL.

1 string reference to 'UpdateScriptTestController::databaseUpdatesMenuItem'
update_script_test.routing.yml in core/modules/system/tests/modules/update_script_test/update_script_test.routing.yml
core/modules/system/tests/modules/update_script_test/update_script_test.routing.yml

File

core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php, line 17

Class

UpdateScriptTestController
Controller routines for update_script_test routes.

Namespace

Drupal\update_script_test\Controller

Code

public function databaseUpdatesMenuItem(Request $request) {

  // @todo Simplify with https://www.drupal.org/node/2548095
  $base_url = str_replace('/update.php', '', $request
    ->getBaseUrl());
  $url = (new Url('system.db_update'))
    ->setOption('base_url', $base_url);
  $build['main'] = [
    '#type' => 'link',
    '#title' => $this
      ->t('Run database updates'),
    '#url' => $url,
    '#access' => $url
      ->access($this
      ->currentUser()),
  ];
  return $build;
}