Data With Unique Get Methods
<?php
/* Site Title - an example of getting a value from the configuration registry */
$siteTitle = \Drupal::config('system.site')->get('name')
/* List of Drupal 8 modules */
$modules = system_rebuild_module_data();
/* List of Drupal 8 site themes */
$themes = system_list('theme');
/* Currently active Drupal 8 site theme */
$currentTheme = \Drupal::config('system.theme')->get('default');
/* List of TWIG Themes AKA Templates (an example of an odd way to get at
some types of data */
$themeList = \Drupal::service('theme.registry')->get();
Direct Database Access
It is possible to directly access the database without having to jump through a bunch of hoops to create your own connection to it. Directly accessing the database isn't exactly encouraged, especially when there is an API provided for the data in question. However, every now and then you may want to get at something not provided by an API, or even access tables that aren't controlled by Drupal directly. In those edge cases, here's how you do it in a forward compatible way:
/* Retrieve all of the URL aliases from the 'url_alias' table. Note the curly
brackets around 'url_alias' - they tell Drupal to automatically add any
database table prefix defined for this instance of Drupal */
$aliasList = \Drupal::database() -> query('SELECT source, alias FROM {url_alias}') -> fetchAll();
/* $aliasList will contain an array of data objects, where each column
retrieved is a public variable in the object */
foreach ($aliasList as $alias) {
$sourcePath = $alias -> source;
$aliasPath = $alias -> alias);
}