diff --git a/CHANGELOG.md b/CHANGELOG.md index 2694db2..b0b089a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,13 @@ ## Draft 1.x.x +- Added empty Develop configuration split - Added dependencies on: - * Administration links access filter (admin_links_access_filter:admin_links_access_filter) + * Administration Links Access Filter (admin_links_access_filter:admin_links_access_filter) + * Configuration Split (config_split:config_split) - Added vendor libraries: - * Administration links access filter (drupal/admin_links_access_filter: **^1.0**) - * Drupal Console (drupal/console: **^1.0**) + * Administration Links Access Filter (drupal/admin_links_access_filter: **^1.0**) + * Configuration Split (drupal/admin_links_access_filter: **^1.0**) + * Drupal Console (drupal/config_split: **^1.0**) * Drush (drush/drush: **^8.1**) - Make sure that all dependencies are prefixed with the project name - Added this file diff --git a/README.md b/README.md index 00f2ea2..02f5f25 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ Just run this command: $ composer create-project lemberg/draft-project my_awesome_project ``` +## Docs + +Everybody loves documentation. We do too! [Check this out](docs). + ## Changelog Changelog can be found here [CHANGELOG.md](CHANGELOG.md) diff --git a/composer.json b/composer.json index f3e4635..df2a704 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,8 @@ "drupal/admin_links_access_filter": "^1.0", "drupal/admin_toolbar": "^1.0", "drupal/adminimal_admin_toolbar": "^1.0", - "drupal/adminimal_theme": "^1.0" + "drupal/adminimal_theme": "^1.0", + "drupal/config_split": "^1.0" }, "repositories": [ { diff --git a/config/install/config_split.config_split.develop.yml b/config/install/config_split.config_split.develop.yml new file mode 100644 index 0000000..983d4cf --- /dev/null +++ b/config/install/config_split.config_split.develop.yml @@ -0,0 +1,13 @@ +langcode: en +status: true +dependencies: { } +id: develop +label: Develop +folder: ../config/develop +module: { } +theme: { } +blacklist: { } +graylist: { } +graylist_dependents: true +graylist_skip_equal: true +weight: 0 diff --git a/docs/config_split.md b/docs/config_split.md new file mode 100644 index 0000000..386cc63 --- /dev/null +++ b/docs/config_split.md @@ -0,0 +1,11 @@ +# Configuration Split + +[Configuration Split](https://www.drupal.org/project/config_split) module allows to define sets of configuration that will get exported to separate directories when exporting, and get merged together when importing. + +Empty **Develop** configuration split is shipped with this profile. + +## How to + +1. We assume that configuration gets exported into a sub directory of the `config` directory above the web root (e.g. `../config/default`). Develop split will be exported to `../config/develop`. Profile will try to create it upon installation automatically. Export directory can be changed any time. + +1. We do not provide any development configuration. Go to `admin/config/development/configuration/config-split/develop/edit` and edit split settings. [Devel](https://www.drupal.org/project/devel) is a great example of a module which must be blacklisted. diff --git a/draft.info.yml b/draft.info.yml index 4f69423..0aac566 100644 --- a/draft.info.yml +++ b/draft.info.yml @@ -17,6 +17,7 @@ dependencies: - admin_links_access_filter:admin_links_access_filter - admin_toolbar:admin_toolbar - adminimal_admin_toolbar:adminimal_admin_toolbar + - config_split:config_split themes: - adminimal_theme:adminimal_theme diff --git a/draft.install b/draft.install index 2bfd81c..e5e60f6 100644 --- a/draft.install +++ b/draft.install @@ -1,8 +1,61 @@ install(['admin_links_access_filter']); } + +/** + * Installs Configuration Split module and Develop configuration split. + */ +function draft_update_8102(&$sandbox = NULL) { + if (!Drupal::moduleHandler()->moduleExists('config_split')) { + \Drupal::service('module_installer')->install(['config_split']); + + $config = _draft_read_develop_config_split(); + _draft_prepare_develop_config_split_directory($config); + + /** @var \Drupal\Core\Config\CachedStorage $config_storage */ + $config_storage = \Drupal::service('config.storage'); + $config_storage->write('config_split.config_split.develop', $config); + } +} + +/** + * Reads Develop configuration split configuration data. + * + * @return array + * Develop configuration split configuration data. + */ +function _draft_read_develop_config_split() { + $config_path = drupal_get_path('profile', 'draft') . '/config/install'; + $source = new FileStorage($config_path); + return $source->read('config_split.config_split.develop'); +} + +/** + * Prepares Develop configuration split export directory. + * + * @param array $config + * Develop configuration split configuration data. + * + * @return bool + * TRUE if Develop configuration split export directory exists and is + * writable, FALSE otherwise. + */ +function _draft_prepare_develop_config_split_directory(array $config) { + $directory = \Drupal::root() . '/' . $config['folder']; + return file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); +}