3 namespace Drupal\webprofiler\State;
5 use Drupal\Core\State\StateInterface;
6 use Drupal\webprofiler\DataCollector\StateDataCollector;
11 class StateWrapper implements StateInterface {
16 * @var \Drupal\Core\State\StateInterface
21 * The state data collector.
23 * @var \Drupal\webprofiler\DataCollector\StateDataCollector
25 private $dataCollector;
28 * StateWrapper constructor.
30 * @param \Drupal\Core\State\StateInterface $state
32 * @param \Drupal\webprofiler\DataCollector\StateDataCollector $dataCollector
33 * The state data collector.
35 public function __construct(StateInterface $state, StateDataCollector $dataCollector) {
36 $this->state = $state;
37 $this->dataCollector = $dataCollector;
43 public function get($key, $default = NULL) {
44 $this->dataCollector->addState($key);
46 return $this->state->get($key, $default);
52 public function getMultiple(array $keys) {
53 foreach ($keys as $key) {
54 $this->dataCollector->addState($key);
57 return $this->state->getMultiple($keys);
63 public function set($key, $value) {
64 $this->state->set($key, $value);
70 public function setMultiple(array $data) {
71 $this->state->setMultiple($data);
77 public function delete($key) {
78 $this->state->delete($key);
84 public function deleteMultiple(array $keys) {
85 $this->state->deleteMultiple($keys);
91 public function resetCache() {
92 $this->state->resetCache();
96 * Passes through all non-tracked calls onto the decorated object.
98 * @param string $method
101 * The passed in arguments.
104 * The return argument of the call.
106 public function __call($method, $args) {
107 return call_user_func_array([$this->state, $method], $args);