You are here

protected function ConfigReadonlyWhitelistTrait::matchesWhitelistPattern in Configuration Read-only mode 8

Check if the given name matches any whitelist pattern.

Parameters

string $name: The config name.

Return value

bool Whether or not there is a match.

2 calls to ConfigReadonlyWhitelistTrait::matchesWhitelistPattern()
ConfigReadonlyStorage::checkLock in src/Config/ConfigReadonlyStorage.php
Check whether config is currently locked.
ReadOnlyFormSubscriber::onFormAlter in src/EventSubscriber/ReadOnlyFormSubscriber.php

File

src/ConfigReadonlyWhitelistTrait.php, line 60

Class

ConfigReadonlyWhitelistTrait
Trait ConfigReadonlyWhitelistTrait.

Namespace

Drupal\config_readonly

Code

protected function matchesWhitelistPattern($name) {

  // Check for matches.
  $patterns = $this
    ->getWhitelistPatterns();
  if ($patterns) {
    foreach ($patterns as $pattern) {
      $escaped = str_replace('\\*', '.*', preg_quote($pattern, '/'));
      if (preg_match('/^' . $escaped . '$/', $name)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}