Dec 19, 2015

Module: "Configuration inspector for Drupal 8"

In my recent post on Missing langcode in configuration schema I discovered that the langcode key in configuration schema is now required by default by Testing module automated tests.

The test results had error messages that said "Uncaught PHP Exception Drupal\Core\Config\Schema\SchemaIncompleteException" and "langcode missing schema".

As a result of that debugging, I got interested in a module called Configuration Inspector for Drupal 8.

Installing the module adds a new tab named Inspect to the page at  
/admin/config/development/configuration

That tab shows all of the Configuration Keys on the site, to which core contributes quite a few.

For the settings for our module, after I removed the langcode key from the .schema.yml file, the tab showed that the configuration key had 1 error. Going to the Raw Data page for the key then showed under Configuration Validation,

array ( 
  'optimizely.settings:langcode' => 'missing schema',
)

This is the gist of what the exceptions had said in the results from running the automated tests, but if I had used this config inspector early on to validate the schema, I would have spotted the error sooner rather than after the testing failed.

     * * *

The inspector also shows the types and the values of individual items. In our case, this includes a project id number whose value had been submitted through a form and stored programmatically by using the Simple Configuration API.

There was no entry shown for the langcode item, which is defined but had no value. I was able to provide one by adding code in hook_install(), again, by using the Simple Configuration API.

Sources:

Configuration inspector for Drupal 8
https://www.drupal.org/project/config_inspector

Configuration API in Drupal 8
https://www.drupal.org/node/1667894

Configuration schema/metadata
https://www.drupal.org/node/1905070
 

2 comments:

  1. Thanks for the info. I also saw this.
    But in my code i used the correct entries, but still the code inspector gives the error:
    'loremipsum.settings:langcode' => 'missing schema'

    Any ideas on what I am missing ?????

    My schema file :
    ================

    loremipsum.settings:
    type: mapping
    label: 'Lorem Ipsum settings'
    mapping:
    loremipsum:
    type: mapping
    mapping:
    page_title:
    type: text
    label: 'Lorem ipsum generator page title:'
    source_text:
    type: text
    label: 'Source text for lorem ipsum generation:'
    langcode:
    type: text
    label: 'Language code:'


    My settings file:
    =================

    loremipsum:
    page_title: 'Lorem ipsum'
    source_text: "Lorem ipsum dolor sit amet"
    langcode: 'en'

    ReplyDelete
  2. Update on my previous post:
    SOLVED.
    The schemafile should be as below.
    so there has to be a mapping for langcode and one for
    loremipsum

    loremipsum.settings:
    type: mapping
    label: 'Lorem Ipsum settings'
    mapping:
    langcode:
    type: string
    label: 'Language code'
    loremipsum:
    type: mapping
    mapping:
    page_title:
    type: text
    label: 'Lorem ipsum generator page title:'
    source_text:
    type: text
    label: 'Source text for lorem ipsum generation:'
    block.settings.loremipsum_block:
    type: block_settings
    label: 'Lorem ipsum block'
    mapping:
    loremipsum_block_settings:

    ReplyDelete