You are here

public function DefaultController::page in Shorten URLs 8

Same name and namespace in other branches
  1. 8.2 modules/record_shorten/src/Controller/DefaultController.php \Drupal\record_shorten\Controller\DefaultController::page()

Page build for Record Shorten

1 string reference to 'DefaultController::page'
record_shorten.routing.yml in modules/record_shorten/record_shorten.routing.yml
modules/record_shorten/record_shorten.routing.yml

File

modules/record_shorten/src/Controller/DefaultController.php, line 17
Contains \Drupal\record_shorten\Controller\DefaultController.

Class

DefaultController
Default controller for the record_shorten module.

Namespace

Drupal\record_shorten\Controller

Code

public function page() {
  $build = [];
  $total = db_query("SELECT COUNT(sid) FROM {record_shorten}")
    ->fetchField();
  $build['summary']['#markup'] = '<p>' . \Drupal::translation()
    ->formatPlural($total, '1 shortened URL has been recorded.', '@count shortened URLs have been recorded.');
  $build['records_table']['#markup'] = record_shorten_records_table();
  $form = \Drupal::formBuilder()
    ->getForm('Drupal\\record_shorten\\Form\\RecordshortenClearAll');
  $build['clear']['#markup'] = \Drupal::service("renderer")
    ->render($form);
  return $build;
}