You are here

public function AcquiaPurgeStateStorageBase::getCounter in Acquia Purge 7

Retrieve a counter object named $key.

Parameters

int $key: The key with which the object is stored in state storage.

Return value

AcquiaPurgeStateCounterInterface The counter.

Overrides AcquiaPurgeStateStorageInterface::getCounter

File

lib/state/AcquiaPurgeStateStorageBase.php, line 87
Contains AcquiaPurgeStateStorageBase.

Class

AcquiaPurgeStateStorageBase
Base layer for state storage backends.

Code

public function getCounter($key) {
  _acquia_purge_load('_acquia_purge_state_counter_interface');
  $class = _acquia_purge_load('_acquia_purge_state_counter');
  if (isset($this->items[$key])) {
    if (!$this->items[$key] instanceof AcquiaPurgeStateCounterInterface) {
      $this->items[$key] = new $class($this, $key, $this->items[$key]
        ->get());
    }
  }
  else {
    $this->items[$key] = new $class($this, $key, 0);
  }
  return $this->items[$key];
}