function ControllerBase::state
Same name in other branches
- 9 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::state()
- 8.9.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::state()
- 11.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::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 config() instead.
Return value
\Drupal\Core\State\StateInterface
File
-
core/
lib/ Drupal/ Core/ Controller/ ControllerBase.php, line 195
Class
- ControllerBase
- Utility base class for thin controllers.
Namespace
Drupal\Core\ControllerCode
protected function state() {
if (!$this->stateService) {
$this->stateService = $this->container()
->get('state');
}
return $this->stateService;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.