Score:1

ConfigNameException: Missing namespace in Config object name xxx

za flag

Drupal\Core\Config\ConfigNameException: Missing namespace in Config object name media_entity_file_replace. in Drupal\Core\Config\ConfigBase::validateName() (line 97 of core/lib/Drupal/Core/Config/ConfigBase.php).

i don't quite get what i have done wrong in my config form

media_entity_file_replace/src/Form/MediaEntityFileReplaceSettingsForm.php

namespace Drupal\media_entity_file_replace\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Configure media_entity_file_replace settings for this site.
 */
class MediaEntityFileReplaceSettingsForm extends ConfigFormBase {
Score:3
de flag

The error comes from Drupal\Core\Config\ConfigBase:

public static function validateName($name) {
  // The name must be namespaced by owner.
  if (strpos($name, '.') === FALSE) {
    throw new ConfigNameException("Missing namespace in Config object name {$name}.");
  }
...

Do you reference a configuration object somewhere in your form without a period? For example:

$config = \Drupal::config('config_with_no_namespace');
apaderno avatar
us flag
This is the reason. I understand why the reason of the exception is not much clear: The documentation for `\Drupal::config()` doesn't make it explicit; it just says that the name of the configuration object, passed to the method, typically corresponds to a configuration file. If the configuration file is media_entity_file_replace.yml, passing *media_entity_file_replace* to `Drupal::config()` seems correct.
Geat avatar
de flag
I agree that it's not clear. I'm sure you get it, but for people who may be confused by this, the rationale is that it avoids configuration name clashes - you might have a configuration for your module called `general_settings` but so might many other modules, namespacing it with the module name ensures it's unique, e.g. `mymodule.general_settings`.
Matoeil avatar
za flag
fixed with renaming config/install/media_entity_file_replace.settings.yml and $config = $this->config('media_entity_file_replace.settings');
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.