Drupal 8  8.0.2
State API

Data Structures

interface  StateInterface
 

Detailed Description

Information about the State API.

The State API is one of several methods in Drupal for storing information. See the Information types topic for an overview of the different types of information.

The basic entry point into the State API is ::state(), which returns an object of class . This class has methods for storing and retrieving state information; each piece of state information is associated with a string-valued key. Example:

// Get the state class.
$state = \Drupal::state();
// Find out when cron was last run; the key is 'system.cron_last'.
$time = $state->get('system.cron_last');
// Set the cron run time to the current request time.
$state->set('system.cron_last', REQUEST_TIME);

For more on the State API, see https://www.drupal.org/developing/api/8/state