Issue #1889752 by alexpott: Fixed Remove unnecessary manifest creation in config_install_default_config().
parent
4fd0af5510
commit
cfb1b5989e
|
@ -24,23 +24,17 @@ const CONFIG_IMPORT_LOCK = 'config_import';
|
||||||
* The name of the module or theme to install default configuration for.
|
* The name of the module or theme to install default configuration for.
|
||||||
*/
|
*/
|
||||||
function config_install_default_config($type, $name) {
|
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';
|
$config_dir = drupal_get_path($type, $name) . '/config';
|
||||||
if (is_dir($config_dir)) {
|
if (is_dir($config_dir)) {
|
||||||
$source_storage = new FileStorage($config_dir);
|
$source_storage = new FileStorage($config_dir);
|
||||||
$target_storage = drupal_container()->get('config.storage');
|
$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(
|
$config_changes = array(
|
||||||
'delete' => array(),
|
'delete' => array(),
|
||||||
'create' => array(),
|
'create' => array(),
|
||||||
|
|
|
@ -35,6 +35,13 @@ class ConfigInstallTest extends DrupalUnitTestBase {
|
||||||
function testModuleInstallation() {
|
function testModuleInstallation() {
|
||||||
$default_config = 'config_test.system';
|
$default_config = 'config_test.system';
|
||||||
$default_configuration_entity = 'config_test.dynamic.default';
|
$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.
|
// Verify that default module config does not exist before installation yet.
|
||||||
$config = config($default_config);
|
$config = config($default_config);
|
||||||
|
@ -42,6 +49,12 @@ class ConfigInstallTest extends DrupalUnitTestBase {
|
||||||
$config = config($default_configuration_entity);
|
$config = config($default_configuration_entity);
|
||||||
$this->assertIdentical($config->isNew(), TRUE);
|
$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.
|
// Install the test module.
|
||||||
$this->enableModules(array('config_test'));
|
$this->enableModules(array('config_test'));
|
||||||
|
|
||||||
|
@ -51,6 +64,13 @@ class ConfigInstallTest extends DrupalUnitTestBase {
|
||||||
$config = config($default_configuration_entity);
|
$config = config($default_configuration_entity);
|
||||||
$this->assertIdentical($config->isNew(), FALSE);
|
$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
|
// Verify that configuration import callback was invoked for the dynamic
|
||||||
// configuration entity.
|
// configuration entity.
|
||||||
$this->assertTrue($GLOBALS['hook_config_import']);
|
$this->assertTrue($GLOBALS['hook_config_import']);
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?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 @@ namespace Drupal\system\Tests\Database;
|
||||||
*/
|
*/
|
||||||
class RegressionTest extends DatabaseTestBase {
|
class RegressionTest extends DatabaseTestBase {
|
||||||
|
|
||||||
/**
|
|
||||||
* Modules to enable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $modules = array('node');
|
|
||||||
|
|
||||||
public static function getInfo() {
|
public static function getInfo() {
|
||||||
return array(
|
return array(
|
||||||
'name' => 'Regression tests',
|
'name' => 'Regression tests',
|
||||||
|
|
Loading…
Reference in New Issue