Drupal 8 Useful Snippets

21 Apr 2015

Drupal 8 is (hopefully) fast approaching and Drop42 is getting into it. See below for some useful snippets we had to lookup / search the code base for :

//current users language code
global $language;
$current_users_language_code = $language->language

//current users account
$account = \Drupal::currentUser();
$current_users_account = $account->getAccount();

//site admin email address
$site_config = \Drupal::config('system.site');
$site_mail = $site_config->get('mail');