0

File below is installed successfully when I install the module 'abc'.


abc/config/install/abc_custom.yml

langcode: en
status: true
dependencies:
  config:
    - field.storage.node.body
    - field.storage.node.field_contact
    - field.storage.node.field_department
  module:
    - node
    - text
    - user
id: abc
label: 'ABC List'
.
.
.

I want to update this config when I install/ uninstall second module 'efg'. On install add one config and module. On uninstall remove the same one config and module and other variables should remain as before.


langcode: en
status: true
dependencies:
  config:
    - field.storage.node.body
    - field.storage.node.field_contact
    - field.storage.node.field_department
    - another.custom.file
  module:
    - node
    - text
    - user
    - another_module
id: abc
label: 'ABC List 2'
.
.
.

efg/efg.install

function efg_install() {
   \Drupal::configFactory()
    ->getEditable('abc_custom')
    ->set('label', 'ABC List 2') //(This works)
    ->set('dependencies', [ //(This part doesn't seem to work for appending)
      'config' => [
        'another.custom.file',
      ],
    ])
    ->save(TRUE);
}
function efg_uninstall() {
   \Drupal::configFactory()
    ->getEditable('abc_custom')
    ->set('label', 'ABC List') //(This works)
    ->clear('dependencies.config.another.custom.file') //(Not working)
    ->save(TRUE);
}

In above code 'label' works but 'dependencies' only shows 'another.custom.file' in array. How do I use config factory to add more dependencies in previous config?

Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.