I'm working on the D8 port of my xbbcode module; my latest sources are here.
The module is supposed to let administrators enable individual BBCode tags either in the global default settings or in an individual text format that overrides those defaults.
The settings structure for both is basically (in YAML):
tags:
abbr:
module: xbbcode
enabled: 0
b:
module: xbbcode_basic
enabled: 1
[...]
The default configuration (set in the annotation comment of my filter plugin class) is
/**
* Provides a filter that converts BBCode to HTML.
*
* @Filter(
* id = "xbbcode",
* title = @Translation("Convert BBCode into HTML."),
* type = Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE,
* settings = {
* "autoclose" = FALSE,
* "override" = FALSE,
* "tags" = {}
* }
* )
*/
However, when I try to create a new text format, I get the following error:
InvalidArgumentException: The configuration property filters.xbbcode.settings.tags.abbr
doesn't exist.
in Drupal\Core\Config\Schema\ArrayElement->get()
(line 97 of core/lib/Drupal/Core/Config/Schema/ArrayElement.php).
Drupal\Core\Config\StorableConfigBase->castValue('filters.xbbcode.settings.tags.abbr', Array)
Drupal\Core\Config\StorableConfigBase->castValue('filters.xbbcode.settings.tags', Array)
Drupal\Core\Config\StorableConfigBase->castValue('filters.xbbcode.settings', Array)
Drupal\Core\Config\StorableConfigBase->castValue('filters.xbbcode', Array)
Drupal\Core\Config\StorableConfigBase->castValue('filters', Array)
Drupal\Core\Config\Config->save()
Drupal\Core\Config\Entity\ConfigEntityStorage->doSave('bb2', Object)
Drupal\Core\Entity\EntityStorageBase->save(Object)
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object)
Drupal\Core\Entity\Entity->save()
Drupal\filter\FilterFormatFormBase->submitForm(Array, Object)
Drupal\filter\FilterFormatAddForm->submitForm(Array, Object)
call_user_func_array(Array, Array)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object)
Drupal\Core\Form\FormBuilder->processForm('filter_format_add_form', Array, Object)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\Core\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
Some examination of the StorableConfigBase class reveal that it seems to insist on merging my configuration values with the existing ones, down to the bottom level, and when it doesn't find the "abbr" key it shuts down. This seems pretty silly, because obviously an array can gain or lose entries when you save it.
The weird thing is that the global defaults have absolutely no problem when I change them with $this->config('xbbcode.settings')->set('tags', [...])->save()
in my own ConfigFormBase
settings form.
Edit: filter.format.* has a config schema, while my module doesn't. I'm not sure how to tell this schema "this array may have a number of keys, each of which has the form {enabled: ..., module: ... }