Last active
August 29, 2015 14:02
-
-
Save dmouse/0b3263acfea7147aa63a to your computer and use it in GitHub Desktop.
Export configuration in Drupal 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Drupal\Core\Config\FileStorage; | |
| // Empty destination dir and then write all .yml files there. | |
| $source_storage = Drupal::service('config.storage'); | |
| $destination_storage = new FileStorage('/tmp/config'); | |
| // Export configuration | |
| foreach ($source_storage->listAll() as $name) { | |
| $destination_storage->write($name, $source_storage->read($name)); | |
| } | |
| // Export configuration collections. | |
| foreach (\Drupal::service('config.storage')->getAllCollectionNames() as $collection) { | |
| $source_storage = $source_storage->createCollection($collection); | |
| $destination_storage = $destination_storage->createCollection($collection); | |
| foreach ($source_storage->listAll() as $name) { | |
| $destination_storage->write($name, $source_storage->read($name)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment