protected function Counter::setDirectly in Purge 8.3
Overwrite the counter value (permission bypass).
Parameters
int|float $value: The new value.
Throws
\Drupal\purge\Plugin\Purge\Purger\Exception\BadBehaviorException Thrown when $value is not a integer, float or when it is negative.
\LogicException Thrown when the object got created without set permission.
3 calls to Counter::setDirectly()
- Counter::decrement in src/
Counter/ Counter.php - Decrease the counter.
- Counter::increment in src/
Counter/ Counter.php - Increase the counter.
- Counter::set in src/
Counter/ Counter.php - Overwrite the counter value.
File
- src/
Counter/ Counter.php, line 117
Class
- Counter
- Provides a numeric counter.
Namespace
Drupal\purge\CounterCode
protected function setDirectly($value) {
if (!(is_float($value) || is_int($value))) {
throw new BadBehaviorException('Given $value is not a integer or float.');
}
if (is_int($value)) {
$value = (double) $value;
}
if ($value < 0.0) {
throw new BadBehaviorException('Given $value can only be zero or positive.');
}
if ($value !== $this->value) {
$this->value = $value;
if (!is_null($this->callback)) {
$callback = $this->callback;
$callback($value);
}
}
}