public static function Config::validateName

Validates the configuration object name.

Throws

\Drupal\Core\Config\ConfigNameException

See also

Config::MAX_NAME_LENGTH

2 calls to Config::validateName()
Config::save in drupal/core/lib/Drupal/Core/Config/Config.php
Saves the configuration object.
ConfigImportSubscriber::onConfigImporterValidate in drupal/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
Validates the configuration to be imported.

File

drupal/core/lib/Drupal/Core/Config/Config.php, line 138
Definition of Drupal\Core\Config\Config.

Class

Config
Defines the default configuration object.

Namespace

Drupal\Core\Config

Code

public static function validateName($name) {

  // The name must be namespaced by owner.
  if (strpos($name, '.') === FALSE) {
    throw new ConfigNameException(format_string('Missing namespace in Config object name @name.', array(
      '@name' => $name,
    )));
  }

  // The name must be shorter than Config::MAX_NAME_LENGTH characters.
  if (strlen($name) > self::MAX_NAME_LENGTH) {
    throw new ConfigNameException(format_string('Config object name @name exceeds maximum allowed length of @length characters.', array(
      '@name' => $name,
      '@length' => self::MAX_NAME_LENGTH,
    )));
  }

  // The name must not contain any of the following characters:
  // : ? * < > " ' / \
  if (preg_match('/[:?*<>"\'\\/\\\\]/', $name)) {
    throw new ConfigNameException(format_string('Invalid character in Config object name @name.', array(
      '@name' => $name,
    )));
  }
}