You are here

public static function Drupal::state in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal.php \Drupal::state()
  2. 9 core/lib/Drupal.php \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

523 calls to Drupal::state()
ActiveWorkspaceUpdateTest::testActiveWorkspaceDuringUpdate in core/modules/workspaces/tests/src/Functional/UpdateSystem/ActiveWorkspaceUpdateTest.php
Tests that there is no active workspace during database updates.
AdvisoriesTestHttpClient::get in core/modules/system/tests/modules/advisory_feed_test/src/AdvisoriesTestHttpClient.php
AdvisoriesTestHttpClient::setTestEndpoint in core/modules/system/tests/modules/advisory_feed_test/src/AdvisoriesTestHttpClient.php
Sets the test endpoint for the advisories JSON feed.
AliasTest::setUp in core/modules/path_alias/tests/src/Kernel/AliasTest.php
AreaEntityTest::testEntityArea in core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php
Tests the area handler.

... See full list

File

core/lib/Drupal.php, line 467

Class

Drupal
Static Service Container wrapper.

Code

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