function MemoryBackend::clearByPrefix

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Flood/MemoryBackend.php \Drupal\Core\Flood\MemoryBackend::clearByPrefix()

Overrides PrefixFloodInterface::clearByPrefix

File

core/lib/Drupal/Core/Flood/MemoryBackend.php, line 60

Class

MemoryBackend
Defines the memory flood backend. This is used for testing.

Namespace

Drupal\Core\Flood

Code

public function clearByPrefix(string $name, string $prefix) : void {
    foreach ($this->events as $event_name => $identifier) {
        $identifier_key = key($identifier);
        $identifier_parts = explode("-", $identifier_key);
        $identifier_prefix = reset($identifier_parts);
        if ($prefix == $identifier_prefix && $name == $event_name) {
            unset($this->events[$event_name][$identifier_key]);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.