Increase flood limit and flood interval in Drupal 8
If you are using Contact form in Drupal 8 and you ever got following error:
"You cannot send more than 5 messages in 1 hour. Try again later"
and if for some reason you want to increase that, then you will want to increase flood limit. However in Drupal 8 just like in Drupal 7 flood control variables are hidden, meaning you can't change them through UI. For Drupal 7 we had a nice Flood control module but it hasn't been ported to Drupal 8 yet.
variable_get and variable_set in Drupal 8
variable_get()/variable_set() and variable_del() API was removed from Drupal 8 in favor of Configuration API.
So in order to save a simple variable in your module firstly you need to decide on a config object name and a name for the settings. Simple settings can be stored in a config object named <module_name>.settings, while for more complex settings it is advisable to use sub-keys.
To get a variable in Drupal 7 you would use:
How to retrieve site wide email address in Drupal 8
In Drupal 7 you would easily retrieve site wide email address through variable:
<?php $site_email = variable_get('site_mail', ''); ?>
However in Drupal 8 variables are gone in favor of configuration objects. So the same functionality in Drupal 8 would be:
<?php $system_site_config = \Drupal::config('system.site'); $site_email = $system_site_config->get('mail'); ?>