The newly committed Configuration system uses xml files to store configuration rather than global variables, impacting the use of variable_set(), variable_get(), and form submission.

The blog post linked above explains how a module would use this new system. The examples module would be a great place a working example of this.

Cheers,

Albert.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rfay’s picture

Version: » 8.x-1.x-dev
Issue tags: -Configuration system

This will be welcome when there's a patch, especially if the person maintaining the patch is willing to make sure it works all the way through the 8.x cycle.

alberto56’s picture

Hi,

thanks for the response.

I'm wondering if you purposefully removed the "Configuration system" tag -- It serves to group issues related to the config management initiaive, across projects. See some examples here.

I believe tagging the issue with "Configuration system" might help people looking for issues related to that initiative, even issues not in core; so you might consider replacing that tag on this issue.

Cheers,

Albert.

rfay’s picture

Issue tags: +Configuration system

I did deliberately remove it, but I was wrong :-) Most of the time when tags like this show up they're because somebody just thought they should make up some tags :-)

Restoring; Thanks for your work on the config system, and hope to get a good demo module in there. It will need tests, and will need ongoing maintenance as 8.x changes.

alberto56’s picture

Title: Example module for the new Drupal 8 configuration system » Example module for the new Drupal 8 configuration system: example_block
Status: Active » Needs review
FileSize
17.13 KB
9.98 KB

Hi all,

Instead of creating a whole new module for this, I decided to use a module that was already in the examples suite for D7, the reason being that I needed to test the upgrade path as well.

So here is a patch that does the following:

- upgrades block_example to use D8's new configuration management system
- defines passing automated tests
- defines an upgrade path from D7 version of block_example, which I tested manually (no automated tests for this yet).

Here is the block_module in two versions: (1) as a patch against 8.x branch of examples. (2) as a stand-alone zip file you can add to your D8 installation.

Cheers,

Albert.

Status: Needs review » Needs work

The last submitted patch, 1615520-4-update-block-module-for-d8-with-config-mgmt.patch, failed testing.

alberto56’s picture

Hmmm, testbot seems to be trying to be breaking, but on my site, the tests _do_ pass.

By the way, I'll be willing provide ongoing maintenance for this as 8.x changes.

rfay’s picture

Thanks for your willingness to do this.

Please do create a new module: configuration_example.module?

Each module is intended to teach exactly one thing. If you need to base it on block_example you can, but its name should tell what you're trying to teach. Please choose the simplest "scaffolding" you can. Block might be OK, but if you can think of something simpler that's great.

The idea is that somebody can look at it and not have to learn *anything* except the config part.

rfay’s picture

@alberto56, there's an FAQ about why tests pass locally but not on the testbot at http://drupal.org/project/testbot.

alberto56’s picture

Thanks @rfay,

Would you agree to a new configuration_example module, but still keeping the block_example module as it is in the patch? A couple of notes:

- first, I need an existing module to test/demonstrate the upgrade path.
- Block example, even though it is not meant to demonstrate config management, will still need to use it, because all modes which previously used variable_get() and variable_set() will need to switch to config management.
- I would not make a lot of sense to add an upgrade hook in a new configuration_example module, so instead I can provide a comment in the configuration_example.install file to the hook presently in block_example in this patch.

Does that make sense to you?

Thanks!

Albert.

rfay’s picture

I'd really like to have you focus on configuration and not confuse things with links between different example modules. The dbtng_example attempted these things for D7, but did it only with comments. If you don't think it can be done with comments... Do you think it would be reasonable to add a Configuration Example to D7 first, demonstrating all the traditional techniques (db tables, cache, info file, whatever)? Then the D8 version could build on that?

It's OK to use the "block" idea as the core, if you can't get any simpler than that. (Simpletest Examples uses a fork of Nodeapi_example). They key is simplicity.

Just rip out anything not related to what you're trying to teach. Rip out everything that's not essential for teaching or functionality.

alberto56’s picture

Do you think it would be reasonable to add a Configuration Example to D7 first

Great idea, that makes a lot of sense, thanks.

alberto56’s picture

Title: Example module for the new Drupal 8 configuration system: example_block » Example module for the new Drupal 8 configuration system: new module needed
alberto56’s picture

Status: Needs work » Needs review
FileSize
19.44 KB

- I have created a config module for D7, see #1630762: Configuration example for D7, so that the upgrade path to D8 may be demonstrated.
- See the enclosed patch for the same module upgraded to D8 using the config system.
- My previous patch, slightly modified, I have submitted in a new issue, because it still works well to demo blocks in D8: #1630760: Update block example module for D8.

Please note that the upgrade path has not been tested yet at all and I'm almost sure it does not work for the more complex configuration (this is in the comments). Let me suggest committing this module as is, and opening a new issue, assigned to me, for the upgrade path.

mrsinguyen’s picture

When i delete the one row config on configuration complex then delete all value in configuration.

Message at http://example.com/dev/drupal-8.x/examples/configuration-complex

No product are defined.
alberto56’s picture

Status: Needs work » Needs review
Issue tags: +Configuration system
FileSize
24.71 KB

Hi,

Here is a new patch which integrates all the same improvements as the latest patch (comment #8) of #1630762: Configuration example for D7, so that the upgrade path to D8 may be demonstrated..

Some notes:

(1) @mrsinguyen thanks for pointing out the bug in your comment #14, above. I am confirming that deleting one item was deleting them all, and have added a test to make sure this does not happen. The reason this was happening is that I was using config::delete() instead of config::clear() to unset the data, so it was deleting everything. It now should work.

(2) I have included a working automated test for the upgrade path.

All tests pass.

Cheers,

Albert.

The last submitted patch, 1615520-15-config-module.patch, failed testing.

alberto56’s picture

Issue tags: -Configuration system

#15: 1615520-15-config-module.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Configuration system

The last submitted patch, 1615520-15-config-module.patch, failed testing.

alberto56’s picture

Hmmm, the testbot does not like the fact that the patch contains a .gz file: "error: cannot apply binary patch to 'configuration_example/tests/drupal-7.configuration_example.database.php.gz' without full index line". I'm not sure why. Still, in my tests, everything works.

rfay’s picture

It's just failing on the git apply. Are you able to do the git apply against this binary manually? I guess I'm surprised that this is required. Applying patches to binary files is not the strong suit of any tool like this.

alberto56’s picture

Status: Needs work » Needs review
FileSize
26.48 KB

My fault, I was not creating the patch correctly. I am now using this technique. Here is the updated patch.

alberto56’s picture

A good chunk of the code is dedicated to implementing and testing an upgrade path from 7.x. Does it make sense to have this here? Or should this be moved to a new module? I have opened an issue about this at #1699440: A dedicated to module to demonstrate hook_update_N() and automatically testing upgrades and updates.

Cheers,

Albert.

alberto56’s picture

Status: Needs review » Active
Mile23’s picture

So is it a hard-wired need to have a .gz file? It might be better to just have the .php file which can then be comprehended by a human in a diff.

Also, I like the idea that you can make a configuration in D7, do an upgrade to D8, and then test the result. In fact, this might be more of a test_data_integrity_example than a configuration_example, which I think is great.

  drupal_set_message(t('Successfully updated the simple configuration variables'));
  $config->save();

Is there a way to check if the config is saved before telling the user it happened?

Also, is anyone working on a D7 module to spit out config YAML files?

Mile23’s picture

Status: Active » Postponed

Marking as postponed for now: #1861598: Examples for Drupal 8 needs relatively stable feature set

Please continue development and discussion as desired.

Mile23’s picture

Status: Postponed » Needs review

Setting this to 'needs review' to see if it still works. :-)

Mile23’s picture

Issue tags: -Configuration system

#21: 1615520-21-config-module.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1615520-21-config-module.patch, failed testing.

Mile23’s picture

Assigned: alberto56 » Unassigned
Issue summary: View changes

Feel free to assign yourself back if you're still working on it.

Mile23’s picture

Title: Example module for the new Drupal 8 configuration system: new module needed » Add simple_config_example

We currently have the config_entity_example. That example demonstrates entities which are more like the taxonomy use-case.

We currently do not have an example for 'simple' config.

I think we should narrow scope here so we have an example which talks about various elements of 'simple' configuration, such as what goes in the config/ directory, what config/install does, how to get at those values, etc. We'll call it simple_config_example

The patch in #21 is old enough that it sets up config entities using hooks, so it might be more work than it's worth to update the whole thing. Though obviously it could be a starting point.

alexandre.todorov’s picture

Mile23’s picture

Title: Add simple_config_example » Add config_simple_example

Thanks, @alexandre.todorov this looks really good. Just some extra stuff we need to make it a proper Examples project module:

  1. Needs a .module file where we @defgroup config_simple_example.
  2. Needs tests which exercise all the paths.
  3. Needs a test to verify that changing the config through the form changes its value.
  4. +++ b/config_simple_example/config/schema/config_simple_example.schema.yml
    @@ -0,0 +1,7 @@
    +  type: config_object
    

    Explain config_object and talk about the other types a little bit.

  5. +++ b/config_simple_example/config/schema/config_simple_example.schema.yml
    @@ -0,0 +1,7 @@
    +  mapping:
    

    Explain what a mapping is.

  6. +++ b/config_simple_example/config_simple_example.config_translation.yml
    @@ -0,0 +1,5 @@
    +config_simple_example.settings:
    

    Explain how this enables translation. Also, let's make a non-translatable config that is somehow excluded here.

  7. +++ b/config_simple_example/config_simple_example.links.menu.yml
    @@ -0,0 +1,12 @@
    +config_simple_example.configuration:
    ...
    +config_simple_example.settings:
    

    These aren't showing in the Tools menu.

  8. +++ b/config_simple_example/config_simple_example.links.task.yml
    --- /dev/null
    +++ b/config_simple_example/config_simple_example.routing.yml
    

    Needs another route to a description page explaining what the user is looking at, with links to the admin pages. Use DescriptionTemplateTrait.

ashishdalvi’s picture

Issue tags: +DrupalMumbaiCodeSprint

Marking this issue for Drupal Mumbai Code Sprint

rcodina’s picture

Title: Add config_simple_example » Add translatable config_simple_example
FileSize
6.76 KB
2.94 KB

I replaced old core property with core_version_requirement. I also addressed some of the feedback on #32.

rcodina’s picture

Version: 8.x-1.x-dev » 4.0.x-dev