Same name and namespace in other branches
  1. 8.9.x 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

526 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.
AdvisoryTestClientMiddleware::setTestEndpoint in core/modules/system/tests/modules/advisory_feed_test/src/AdvisoryTestClientMiddleware.php
Sets the test endpoint for the advisories JSON feed.
AdvisoryTestClientMiddleware::__invoke in core/modules/system/tests/modules/advisory_feed_test/src/AdvisoryTestClientMiddleware.php
HTTP middleware that replaces URI for advisory requests.
AjaxMaintenanceModeTest::testAjaxCallMaintenanceMode in core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxMaintenanceModeTest.php
Tests maintenance message only appears once on an AJAX call.
AjaxTestController::httpMethods in core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
Provides an Ajax link used with different HTTP methods.

... See full list

File

core/lib/Drupal.php, line 480

Class

Drupal
Static Service Container wrapper.

Code

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