protected ConfigInstaller::createConfiguration($collection, array $config_to_create)
Creates configuration in a collection based on the provided list.
Parameters
string $collection: The configuration collection.
array $config_to_create: An array of configuration data to create, keyed by name.
File
- core/lib/Drupal/Core/Config/ConfigInstaller.php, line 265
Class
Namespace
Drupal\Core\Config
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | protected function createConfiguration( $collection , array $config_to_create ) { // Order the configuration to install in the order of dependencies. if ( $collection == StorageInterface::DEFAULT_COLLECTION) { $dependency_manager = new ConfigDependencyManager(); $config_names = $dependency_manager ->setData( $config_to_create ) ->sortAll(); } else { $config_names = array_keys ( $config_to_create ); } foreach ( $config_names as $name ) { // Allow config factory overriders to use a custom configuration object if // they are responsible for the collection. $overrider = $this ->configManager->getConfigCollectionInfo()->getOverrideService( $collection ); if ( $overrider ) { $new_config = $overrider ->createConfigObject( $name , $collection ); } else { $new_config = new Config( $name , $this ->getActiveStorages( $collection ), $this ->eventDispatcher, $this ->typedConfig); } if ( $config_to_create [ $name ] !== FALSE) { $new_config ->setData( $config_to_create [ $name ]); // Add a hash to configuration created through the installer so it is // possible to know if the configuration was created by installing an // extension and to track which version of the default config was used. if (! $this ->isSyncing() && $collection == StorageInterface::DEFAULT_COLLECTION) { $new_config ->set( '_core.default_config_hash' , Crypt::hashBase64(serialize( $config_to_create [ $name ]))); } } if ( $collection == StorageInterface::DEFAULT_COLLECTION && $entity_type = $this ->configManager->getEntityTypeIdByName( $name )) { // If we are syncing do not create configuration entities. Pluggable // configuration entities can have dependencies on modules that are // not yet enabled. This approach means that any code that expects // default configuration entities to exist will be unstable after the // module has been enabled and before the config entity has been // imported. if ( $this ->isSyncing()) { continue ; } /** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $entity_storage */ $entity_storage = $this ->configManager ->getEntityManager() ->getStorage( $entity_type ); // It is possible that secondary writes can occur during configuration // creation. Updates of such configuration are allowed. if ( $this ->getActiveStorages( $collection )->exists( $name )) { $id = $entity_storage ->getIDFromConfigName( $name , $entity_storage ->getEntityType()->getConfigPrefix()); $entity = $entity_storage ->load( $id ); $entity = $entity_storage ->updateFromStorageRecord( $entity , $new_config ->get()); } else { $entity = $entity_storage ->createFromStorageRecord( $new_config ->get()); } if ( $entity ->isInstallable()) { $entity ->trustData()->save(); } } else { $new_config ->save(TRUE); } } } |
Please login to continue.