UpdateScriptTestController.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php
  2. 8.9.x core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php
  3. 11.x core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php

Namespace

Drupal\update_script_test\Controller

File

core/modules/system/tests/modules/update_script_test/src/Controller/UpdateScriptTestController.php

View source
<?php

namespace Drupal\update_script_test\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Request;

/**
 * Controller routines for update_script_test routes.
 */
class UpdateScriptTestController extends ControllerBase {
    
    /**
     * Outputs a link to the database updates URL.
     */
    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;
    }

}

Classes

Title Deprecated Summary
UpdateScriptTestController Controller routines for update_script_test routes.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.