W3cubDocs

/Drupal 8

public static function Drupal::state

public static Drupal::state()

Returns the state storage service.

Use this to store machine-generated data, local to a specific environment that does not need deploying and does not need human editing; for example, the last time cron was run. Data which needs to be edited by humans and needs to be the same across development, production, etc. environments (for example, the system maintenance message) should use \Drupal::config() instead.

Return value

\Drupal\Core\State\StateInterface

File

core/lib/Drupal.php, line 408
Contains \Drupal.

Class

Drupal
Static Service Container wrapper.

Code

public static function state() {
  return static::getContainer()->get('state');
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal::state/8.1.x