You are here

protected function ConfigReadonlyStorage::checkLock in Configuration Read-only mode 8

Same name and namespace in other branches
  1. 7 lib/Drupal/config_readonly/Config/ConfigReadonlyStorage.php \Drupal\config_readonly\Config\ConfigReadonlyStorage::checkLock()

Check whether config is currently locked.

Parameters

string $name: Check for a specific lock config.

Throws

\Drupal\config_readonly\Exception\ConfigReadonlyStorageException

4 calls to ConfigReadonlyStorage::checkLock()
ConfigReadonlyStorage::delete in src/Config/ConfigReadonlyStorage.php
ConfigReadonlyStorage::deleteAll in src/Config/ConfigReadonlyStorage.php
ConfigReadonlyStorage::rename in src/Config/ConfigReadonlyStorage.php
ConfigReadonlyStorage::write in src/Config/ConfigReadonlyStorage.php

File

src/Config/ConfigReadonlyStorage.php, line 123

Class

ConfigReadonlyStorage
Defines a config read-only storage controller.

Namespace

Drupal\config_readonly\Config

Code

protected function checkLock($name = '') {

  // If settings.php says to lock config changes and if the config importer
  // isn't running (we do not want to lock config imports), then throw an
  // exception.
  // @see \Drupal\Core\Config\ConfigImporter::alreadyImporting()
  if (Settings::get('config_readonly') && $this->lock
    ->lockMayBeAvailable(ConfigImporter::LOCK_NAME)) {
    $request = $this->requestStack
      ->getCurrentRequest();
    if ($request && $request->attributes
      ->get(RouteObjectInterface::ROUTE_NAME) === 'system.db_update') {

      // We seem to be in the middle of running update.php.
      // @see \Drupal\Core\Update\UpdateKernel::setupRequestMatch()
      // @todo - always allow or support a flag for blocking it?
      return;
    }

    // Don't block particular patterns.
    if ($name && $this
      ->matchesWhitelistPattern($name)) {
      return;
    }
    throw new ConfigReadonlyStorageException('Your site configuration active store is currently locked.');
  }
}