Commit cfb1b598 authored by webchick's avatar webchick

Issue #1889752 by alexpott: Fixed Remove unnecessary manifest creation in...

Issue #1889752 by alexpott: Fixed Remove unnecessary manifest creation in config_install_default_config().
parent 4fd0af55
......@@ -24,23 +24,17 @@
* The name of the module or theme to install default configuration for.
*/
function config_install_default_config($type, $name) {
// If this module defines any ConfigEntity types then create an empty
// manifest file for each of them.
foreach (config_get_module_config_entities($name) as $entity_info) {
config('manifest.' . $entity_info['config_prefix'])->save();
}
$config_dir = drupal_get_path($type, $name) . '/config';
if (is_dir($config_dir)) {
$source_storage = new FileStorage($config_dir);
$target_storage = drupal_container()->get('config.storage');
// If this module defines any ConfigEntity types, then create a manifest file
// for each of them with a listing of the objects it maintains.
foreach (config_get_module_config_entities($name) as $entity_type => $entity_info) {
$manifest_config = config('manifest.' . $entity_info['config_prefix']);
$manifest_data = array();
foreach ($source_storage->listAll($entity_info['config_prefix']) as $config_name) {
list(, , $id) = explode('.', $config_name);
$manifest_data[$id]['name'] = $config_name;
}
$manifest_config->setData($manifest_data)->save();
}
$config_changes = array(
'delete' => array(),
'create' => array(),
......
......@@ -35,6 +35,13 @@ function setUp() {
function testModuleInstallation() {
$default_config = 'config_test.system';
$default_configuration_entity = 'config_test.dynamic.default';
$default_config_manifest = 'manifest.config_test.dynamic';
$expected_manifest_data = array(
'default' => array(
'name' => 'config_test.dynamic.default',
),
);
$default_empty_config_manifest = 'manifest.config_test.empty_manifest';
// Verify that default module config does not exist before installation yet.
$config = config($default_config);
......@@ -42,6 +49,12 @@ function testModuleInstallation() {
$config = config($default_configuration_entity);
$this->assertIdentical($config->isNew(), TRUE);
// Verify that configuration entity manifests do not exist.
$config = config($default_config_manifest);
$this->assertIdentical($config->isNew(), TRUE);
$config = config($default_empty_config_manifest);
$this->assertIdentical($config->isNew(), TRUE);
// Install the test module.
$this->enableModules(array('config_test'));
......@@ -51,6 +64,13 @@ function testModuleInstallation() {
$config = config($default_configuration_entity);
$this->assertIdentical($config->isNew(), FALSE);
// Verify that configuration entity manifests have been created with
// expected contents.
$config = config($default_config_manifest);
$this->assertIdentical($config->get(), $expected_manifest_data);
$config = config($default_empty_config_manifest);
$this->assertIdentical($config->get(), array());
// Verify that configuration import callback was invoked for the dynamic
// configuration entity.
$this->assertTrue($GLOBALS['hook_config_import']);
......
<?php
/**
* @file
* Definition of Drupal\config_test\Plugin\Core\Entity\ConfigTestEmptyManifest.
*/
namespace Drupal\config_test\Plugin\Core\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Defines the ConfigTestEmptyManifest configuration entity.
*
* @Plugin(
* id = "config_test_empty_manifest",
* label = @Translation("Test empty manifest creation"),
* module = "config_test",
* controller_class = "Drupal\config_test\ConfigTestStorageController",
* config_prefix = "config_test.empty_manifest",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid"
* }
* )
*/
class ConfigTestEmptyManifest extends ConfigEntityBase {
/**
* The machine name for the configuration entity.
*
* @var string
*/
public $id;
/**
* The UUID for the configuration entity.
*
* @var string
*/
public $uuid;
/**
* The human-readable name of the configuration entity.
*
* @var string
*/
public $label;
}
......@@ -12,13 +12,6 @@
*/
class RegressionTest extends DatabaseTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node');
public static function getInfo() {
return array(
'name' => 'Regression tests',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment