drupal-state
Installation
SKILL.md
Drupal State API
State is for runtime data that should persist across requests but is NOT configuration. Use Config for user-managed settings. Use State for internal operational data (last cron run, migration status, etc.).
Basic Usage
use Drupal\Core\State\StateInterface;
// Inject
public function __construct(
private readonly StateInterface $state,
) {}
// Get
$value = $this->state->get('my_module.last_run');
$value = $this->state->get('my_module.last_run', $default_value);