Config http://lobsterr.me/ en How to load a configuration file from module in Drupal 9? http://lobsterr.me/post/how-load-configuration-file-module-drupal-9 <span class="field field--name-title field--type-string field--label-hidden">How to load a configuration file from module in Drupal 9?</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">LOBsTerr</span></span> <span class="field field--name-created field--type-created field--label-hidden">02/02/2021</span> <div class="field field--name-f-content field--type-entity-reference-revisions field--label-hidden field__items"> <div class="field__item"> <div class="paragraph paragraph--type--l-text paragraph--view-mode--default"> <div class="clearfix text-formatted field field--name-f-text field--type-text-long field--label-hidden field__item"><p>In some cases we want to load a configuration file from optional / install folders. For example to compare it with active config and apply new changes.<br /> To load a configuration from install folder user the next code snippet.</p> <pre> <code class="language-php">use Drupal\Core\Config\ExtensionInstallStorage; $field_storage = 'field.storage.group_content.grequest_status'; $install_storage = new ExtensionInstallStorage( \Drupal::service('config.storage'), InstallStorage::CONFIG_INSTALL_DIRECTORY, InstallStorage::DEFAULT_COLLECTION, TRUE, NULL );</code></pre> <p>From optional folder</p> <pre> <code class="language-php">use Drupal\Core\Config\ExtensionInstallStorage; $name = 'views.view.group_pending_members'; $optional_storage = new ExtensionInstallStorage( \Drupal::service('config.storage'), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, InstallStorage::DEFAULT_COLLECTION, TRUE, NULL ); </code></pre> <p>and schema configuration</p> <pre> <code class="language-php">use Drupal\Core\Config\ExtensionInstallStorage; $name = 'views.view.group_pending_members'; $optional_storage = new ExtensionInstallStorage( \Drupal::service('config.storage'), InstallStorage::CONFIG_SCHEMA_DIRECTORY, InstallStorage::DEFAULT_COLLECTION, TRUE, NULL ); </code></pre> <p> </p> </div> </div> </div> </div> <div class="field field--name-f-tags field--type-entity-reference field--label-hidden field__items"> <div class="field__item btn btn-secondary"><a href="/tags/drupal-9" hreflang="en">Drupal 9</a></div> <div class="field__item btn btn-secondary"><a href="/tags/configuration-api" hreflang="en">Configuration API</a></div> <div class="field__item btn btn-secondary"><a href="/tags/config" hreflang="en">Config</a></div> </div> <section class="field field--name-f-comments field--type-comment field--label-above comment-wrapper"> </section> Tue, 02 Feb 2021 22:28:17 +0000 LOBsTerr 34 at http://lobsterr.me