updated core and modules
This commit is contained in:
@@ -3,10 +3,10 @@ type: module
|
||||
description: 'Provides basic revert and update functionality for other modules'
|
||||
# core: 8.x
|
||||
dependencies:
|
||||
- config
|
||||
- drupal:config
|
||||
|
||||
# Information added by Drupal.org packaging script on 2016-03-08
|
||||
version: '8.x-1.1'
|
||||
# Information added by Drupal.org packaging script on 2017-01-18
|
||||
version: '8.x-1.3'
|
||||
core: '8.x'
|
||||
project: 'config_update'
|
||||
datestamp: 1457466840
|
||||
datestamp: 1484770686
|
||||
|
||||
@@ -4,8 +4,8 @@ services:
|
||||
arguments: ['@string_translation']
|
||||
|
||||
config_update.config_list:
|
||||
class: Drupal\config_update\ConfigLister
|
||||
arguments: ['@entity.manager', '@config.storage', '@config_update.extension_storage', '@config_update.extension_optional_storage']
|
||||
class: Drupal\config_update\ConfigListerWithProviders
|
||||
arguments: ['@entity.manager', '@config.storage', '@config_update.extension_storage', '@config_update.extension_optional_storage', '@module_handler', '@theme_handler']
|
||||
|
||||
config_update.config_update:
|
||||
class: Drupal\config_update\ConfigReverter
|
||||
|
||||
@@ -85,15 +85,16 @@ drush config-list-types (clt)
|
||||
drush config-added-report (cra)
|
||||
drush config-missing-report (crm)
|
||||
drush config-different-report (crd)
|
||||
drush config-inactive-report (cri)
|
||||
Run config reports (see below).
|
||||
|
||||
drush config-diff (cfd)
|
||||
Show config differences for one item between active and imported (see below).
|
||||
|
||||
The report commands run reports that tell what config has been added, is
|
||||
missing, or is different between your active site configuration and the imported
|
||||
default configuration from config/install directories of your installed profile,
|
||||
modules, and themes.
|
||||
missing, is inactive, or is different between your active site configuration and
|
||||
the imported default configuration from config/install directories of your
|
||||
installed profile, modules, and themes.
|
||||
|
||||
For each report except "added", the first argument is one of:
|
||||
- type: Runs the report for a configuration type; use drush config-list-types to
|
||||
@@ -108,7 +109,8 @@ module, theme, or install profile you want to run the report for. For the
|
||||
configuration type.
|
||||
|
||||
These are the same as the reports you get in the UI, which is described above;
|
||||
the only difference is that in Drush the report is separated into pieces.
|
||||
the difference is that in Drush the report is separated into pieces, and the
|
||||
UI report sections have more columns giving information about each config item.
|
||||
|
||||
Once you have found a configuration item with differences, you can view the
|
||||
differences using the config-diff command. This is a normalized/formatted diff
|
||||
@@ -130,16 +132,25 @@ different, you can:
|
||||
|
||||
- Export them - see drush config-export.
|
||||
|
||||
- Import missing configuration or revert to provided default values. To do this:
|
||||
- Import missing configuration or revert to provided default values. There are
|
||||
Drush commands to do this:
|
||||
|
||||
(1) Locate the configuration file in the install profile, module, or theme
|
||||
config/install directory.
|
||||
drush config-revert (cfr)
|
||||
Revert a config item found in a "different" report to the current version in
|
||||
the module, theme, or install profile that provides it.
|
||||
|
||||
(2) Copy this file to your configuration staging directory.
|
||||
drush config-revert-multiple (cfrm)
|
||||
Revert all config items of one type or from one module, theme, or install
|
||||
profile to the provided versions.
|
||||
|
||||
(3) Run drush config-import. You might want to use the --preview option to see
|
||||
what differences you are about to import, before running the import, or
|
||||
use the drush config-diff command to look at individual differences.
|
||||
drush config-import-missing (cfi)
|
||||
Import a config item found in a "missing" or "inactive" report from the
|
||||
current version in the module, theme, or install profile that provides it.
|
||||
|
||||
You can also to use the drush config-import command to import/update multiple
|
||||
configuration items. But this requires that you locate the files containing the
|
||||
configuration you want to import, and copy them to your configuration staging
|
||||
directory.
|
||||
|
||||
|
||||
IMPORTANT NOTES
|
||||
|
||||
+123
-4
@@ -74,7 +74,7 @@ function config_update_ui_drush_command() {
|
||||
];
|
||||
|
||||
$items['config-different-report'] = [
|
||||
'description' => 'Display a list of config items that differ from the versions imported from your installed modules, themes, or install profile. See config-diff to show what the differences are.',
|
||||
'description' => 'Display a list of config items that differ from the versions provided by your installed modules, themes, or install profile. See config-diff to show what the differences are.',
|
||||
'arguments' => [
|
||||
'type' => 'Run the report for: module, theme, profile, or "type" for config entity type.',
|
||||
'name' => 'The machine name of the module, theme, etc. to report on. See config-list-types to list types for config entities; you can also use system.all for all types, or system.simple for simple config.',
|
||||
@@ -83,7 +83,6 @@ function config_update_ui_drush_command() {
|
||||
'examples' => [
|
||||
'drush config-different-report type action' => 'Displays the differing config report for action config.',
|
||||
],
|
||||
'drupal dependencies' => ['config_update_ui'],
|
||||
'aliases' => ['crd'],
|
||||
'core' => ['8+'],
|
||||
'outputformat' => [
|
||||
@@ -104,6 +103,46 @@ function config_update_ui_drush_command() {
|
||||
'core' => ['8+'],
|
||||
];
|
||||
|
||||
$items['config-revert'] = [
|
||||
'description' => 'Revert one config item in active storage to the version provided by an installed module, theme, or install profile.',
|
||||
'arguments' => [
|
||||
'name' => 'The config item to revert. See config-different-report to list config items that are different.',
|
||||
],
|
||||
'required-arguments' => 1,
|
||||
'examples' => [
|
||||
'drush config-revert block.block.bartik_search' => 'Revert the config for the search block in the Bartik theme to the version provided by the install profile.',
|
||||
],
|
||||
'aliases' => ['cfr'],
|
||||
'core' => ['8+'],
|
||||
];
|
||||
|
||||
$items['config-import-missing'] = [
|
||||
'description' => 'Import a missing or inactive config item provided by an installed module, theme, or install profile. Be sure that requirements are met.',
|
||||
'arguments' => [
|
||||
'name' => 'The name of the config item to import (usually the ID you would see in the user interface). See config-missing-report to list config items that are missing, and config-inactive-report to list config items that are inactive.',
|
||||
],
|
||||
'required-arguments' => 1,
|
||||
'examples' => [
|
||||
'drush config-import-missing block.block.bartik_search' => 'Import the config for the search block in the Bartik theme from the version provided by the install profile.',
|
||||
],
|
||||
'aliases' => ['cfi'],
|
||||
'core' => ['8+'],
|
||||
];
|
||||
|
||||
$items['config-revert-multiple'] = [
|
||||
'description' => 'Revert a set of config items to the versions provided by installed modules, themes, or install profiles. A set is all differing items from one extension, or one type of configuration.',
|
||||
'arguments' => [
|
||||
'type' => 'Type of set to revert: "module" for all items from a module, "theme" for all items from a theme, "profile" for all items from the install profile, or "type" for all items of one config entity type. See config-different-report to list config items that are different.',
|
||||
'name' => 'The machine name of the module, theme, etc. to revert items of. All items in the corresponding config-different-report will be reverted.',
|
||||
],
|
||||
'required-arguments' => 2,
|
||||
'examples' => [
|
||||
'drush config-revert-multiple type action' => 'Revert all differing config items of type action.',
|
||||
],
|
||||
'aliases' => ['cfrm'],
|
||||
'core' => ['8+'],
|
||||
];
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
@@ -222,11 +261,91 @@ function drush_config_update_ui_config_diff($name) {
|
||||
|
||||
$extension = $reverter->getFromExtension('', $name);
|
||||
$active = $reverter->getFromActive('', $name);
|
||||
if ($extension && !$active) {
|
||||
if ($extension && $active) {
|
||||
$diff = $differ->diff($extension, $active);
|
||||
drush_print($formatter->format($diff));
|
||||
$output = $formatter->format($diff);
|
||||
return $output;
|
||||
}
|
||||
else {
|
||||
drush_print(dt('Config is missing, cannot diff'), 0, STDERR);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the drush config-revert command.
|
||||
*
|
||||
* @param string $name
|
||||
* Config item to revert.
|
||||
*/
|
||||
function drush_config_update_ui_config_revert($name) {
|
||||
$lister = \Drupal::service('config_update.config_list');
|
||||
$reverter = \Drupal::service('config_update.config_update');
|
||||
$manager = \Drupal::service('entity.manager');
|
||||
|
||||
// The revert command needs the type and the unprefixed name.
|
||||
$type = $lister->getTypeNameByConfigName($name);
|
||||
$shortname = $name;
|
||||
if ($type && $type != 'system.simple') {
|
||||
$definition = $manager->getDefinition($type);
|
||||
$prefix = $definition->getConfigPrefix() . '.';
|
||||
if (strpos($name, $prefix) === 0) {
|
||||
$shortname = substr($name, strlen($prefix));
|
||||
}
|
||||
}
|
||||
|
||||
if ($reverter->revert($type, $shortname)) {
|
||||
drush_print(dt('The configuration item @name was reverted to its source.', ['@name' => $name]));
|
||||
}
|
||||
else {
|
||||
drush_print(dt('There was an error and the configuration item @name was not reverted.', ['@name' => $name]), 0, STDERR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the drush config-import-missing command.
|
||||
*
|
||||
* @param string $name
|
||||
* Name of config item to import, without prefix.
|
||||
*/
|
||||
function drush_config_update_ui_config_import_missing($name) {
|
||||
$lister = \Drupal::service('config_update.config_list');
|
||||
$reverter = \Drupal::service('config_update.config_update');
|
||||
$manager = \Drupal::service('entity.manager');
|
||||
|
||||
// The import command needs the type and the unprefixed name.
|
||||
$type = $lister->getTypeNameByConfigName($name);
|
||||
$shortname = $name;
|
||||
if ($type && $type != 'system.simple') {
|
||||
$definition = $manager->getDefinition($type);
|
||||
$prefix = $definition->getConfigPrefix() . '.';
|
||||
if (strpos($name, $prefix) === 0) {
|
||||
$shortname = substr($name, strlen($prefix));
|
||||
}
|
||||
}
|
||||
|
||||
if ($reverter->import($type, $shortname)) {
|
||||
drush_print(dt('The configuration item @name was imported from its source.', ['@name' => $name]));
|
||||
}
|
||||
else {
|
||||
drush_print(dt('There was an error and the configuration item @name was not imported.', ['@name' => $name]), 0, STDERR);
|
||||
drush_print(dt('The configuration was imported from its source.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the drush config-revert-multiple command.
|
||||
*
|
||||
* @param string $type
|
||||
* Type of config to revert: 'type', 'module', 'theme', or 'profile'.
|
||||
* @param string $name
|
||||
* Machine name of type to revert.
|
||||
*/
|
||||
function drush_config_update_ui_config_revert_multiple($type, $name) {
|
||||
// This command will print an error if there are no items to revert.
|
||||
$different = drush_config_update_ui_config_different_report($type, $name);
|
||||
foreach ($different as $name) {
|
||||
// This command will print a message if it succeeds or fails for each item.
|
||||
drush_config_update_ui_config_revert($name);
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines stubs for Drush functions and constants so tests can run.
|
||||
*
|
||||
* @see \Drupal\config_update_ui\Tests\ConfigUpdateTest
|
||||
*/
|
||||
|
||||
if (!function_exists('drush_print')) {
|
||||
function drush_print() {}
|
||||
}
|
||||
if (!function_exists('dt')) {
|
||||
function dt($text) { return $text; }
|
||||
}
|
||||
defined('STDERR') or define('STDERR', 25);
|
||||
+5
-5
@@ -4,11 +4,11 @@ description: 'Adds an updates report and revert functionality to configuration m
|
||||
# core: 8.x
|
||||
configure: config_update.report
|
||||
dependencies:
|
||||
- config_update
|
||||
- config
|
||||
- config_update:config_update
|
||||
- drupal:config
|
||||
|
||||
# Information added by Drupal.org packaging script on 2016-03-08
|
||||
version: '8.x-1.1'
|
||||
# Information added by Drupal.org packaging script on 2017-01-18
|
||||
version: '8.x-1.3'
|
||||
core: '8.x'
|
||||
project: 'config_update'
|
||||
datestamp: 1457466840
|
||||
datestamp: 1484770686
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ function config_update_ui_help($route_name, RouteMatchInterface $route_match) {
|
||||
|
||||
case 'config_update_ui.report':
|
||||
$output = '';
|
||||
$output .= '<p>' . t('This report shows which default configuration items provided by the current versions of your installed modules, themes, and install profile differ from the active configuration of your site. You can generate the report for all configuration of a certain type, or for a particular installed module, theme, or your install profile.') . '</p>';
|
||||
$output .= '<p>' . t('This report shows which default configuration items provided by the current versions of your installed modules, themes, and install profile differ from the active configuration of your site. You can generate the report for all configuration of a certain type, or for a particular installed module, theme, or your install profile (only modules, themes, and install profiles that actually provide configuration are listed).') . '</p>';
|
||||
$output .= '<p>' . t('Some configuration provided by modules has dependencies, and is only added to your system when all the dependencies are satisfied. This is known as <em>optional</em> configuration.') . '</p>';
|
||||
$output .= '<p>' . t('Differences, including missing and added configuration, can be due to either an updated module or theme providing different configuration from when you installed it, or to changes made by site administrators. This report does not differentiate between these two sources for differences, and note that an install profile can also silently override module/theme configuration. Overrides (such as those in your settings.php file) and translations are not considered when looking at differences.') . '</p>';
|
||||
return $output;
|
||||
|
||||
+81
-27
@@ -9,7 +9,7 @@ use Drupal\Core\Extension\ThemeHandlerInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\config_update\ConfigDiffInterface;
|
||||
use Drupal\config_update\ConfigListInterface;
|
||||
use Drupal\config_update\ConfigListByProviderInterface;
|
||||
use Drupal\config_update\ConfigRevertInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
@@ -28,7 +28,7 @@ class ConfigUpdateController extends ControllerBase {
|
||||
/**
|
||||
* The config lister.
|
||||
*
|
||||
* @var \Drupal\config_update\ConfigListInterface
|
||||
* @var \Drupal\config_update\ConfigListByProviderInterface
|
||||
*/
|
||||
protected $configList;
|
||||
|
||||
@@ -65,7 +65,7 @@ class ConfigUpdateController extends ControllerBase {
|
||||
*
|
||||
* @param \Drupal\config_update\ConfigDiffInterface $config_diff
|
||||
* The config differ.
|
||||
* @param \Drupal\config_update\ConfigListInterface $config_list
|
||||
* @param \Drupal\config_update\ConfigListByProviderInterface $config_list
|
||||
* The config lister.
|
||||
* @param \Drupal\config_update\ConfigRevertInterface $config_update
|
||||
* The config reverter.
|
||||
@@ -76,7 +76,7 @@ class ConfigUpdateController extends ControllerBase {
|
||||
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
|
||||
* The theme handler.
|
||||
*/
|
||||
public function __construct(ConfigDiffInterface $config_diff, ConfigListInterface $config_list, ConfigRevertInterface $config_update, DiffFormatter $diff_formatter, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
|
||||
public function __construct(ConfigDiffInterface $config_diff, ConfigListByProviderInterface $config_list, ConfigRevertInterface $config_update, DiffFormatter $diff_formatter, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
|
||||
$this->configDiff = $config_diff;
|
||||
$this->configList = $config_list;
|
||||
$this->configRevert = $config_update;
|
||||
@@ -241,7 +241,7 @@ class ConfigUpdateController extends ControllerBase {
|
||||
$definitions = $this->configList->listTypes();
|
||||
$links = [];
|
||||
foreach ($definitions as $entity_type => $definition) {
|
||||
$links['type_' . $entity_type] = [
|
||||
$links['report_type_' . $entity_type] = [
|
||||
'title' => $definition->getLabel(),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'type', 'name' => $entity_type]),
|
||||
];
|
||||
@@ -250,11 +250,11 @@ class ConfigUpdateController extends ControllerBase {
|
||||
uasort($links, [$this, 'sortLinks']);
|
||||
|
||||
$links = [
|
||||
'type_all' => [
|
||||
'report_type_all' => [
|
||||
'title' => $this->t('All types'),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'type', 'name' => 'system.all']),
|
||||
],
|
||||
'type_system.simple' => [
|
||||
'report_type_system.simple' => [
|
||||
'title' => $this->t('Simple configuration'),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'type', 'name' => 'system.simple']),
|
||||
],
|
||||
@@ -275,8 +275,8 @@ class ConfigUpdateController extends ControllerBase {
|
||||
$modules = $this->moduleHandler->getModuleList();
|
||||
$links = [];
|
||||
foreach ($modules as $machine_name => $module) {
|
||||
if ($machine_name != $profile) {
|
||||
$links['module_' . $machine_name] = [
|
||||
if ($machine_name != $profile && $this->configList->providerHasConfig('module', $machine_name)) {
|
||||
$links['report_module_' . $machine_name] = [
|
||||
'title' => $this->moduleHandler->getName($machine_name),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'module', 'name' => $machine_name]),
|
||||
];
|
||||
@@ -298,10 +298,12 @@ class ConfigUpdateController extends ControllerBase {
|
||||
$themes = $this->themeHandler->listInfo();
|
||||
$links = [];
|
||||
foreach ($themes as $machine_name => $theme) {
|
||||
$links['theme_' . $machine_name] = [
|
||||
'title' => $this->themeHandler->getName($machine_name),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'theme', 'name' => $machine_name]),
|
||||
];
|
||||
if ($this->configList->providerHasConfig('theme', $machine_name)) {
|
||||
$links['report_theme_' . $machine_name] = [
|
||||
'title' => $this->themeHandler->getName($machine_name),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'theme', 'name' => $machine_name]),
|
||||
];
|
||||
}
|
||||
}
|
||||
uasort($links, [$this, 'sortLinks']);
|
||||
|
||||
@@ -315,21 +317,24 @@ class ConfigUpdateController extends ControllerBase {
|
||||
],
|
||||
];
|
||||
|
||||
// Profile is just one option.
|
||||
$links = [];
|
||||
$links['profile_' . $profile] = [
|
||||
'title' => $this->moduleHandler->getName($profile),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'profile']),
|
||||
];
|
||||
$build['links']['#rows'][] = [
|
||||
$this->t('Installation profile'),
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'operations',
|
||||
'#links' => $links,
|
||||
|
||||
// Profile is just one option.
|
||||
if ($this->configList->providerHasConfig('profile', $profile)) {
|
||||
$links['report_profile_' . $profile] = [
|
||||
'title' => $this->moduleHandler->getName($profile),
|
||||
'url' => Url::fromRoute('config_update_ui.report', ['report_type' => 'profile']),
|
||||
];
|
||||
$build['links']['#rows'][] = [
|
||||
$this->t('Installation profile'),
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'operations',
|
||||
'#links' => $links,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
];
|
||||
}
|
||||
|
||||
return $build;
|
||||
}
|
||||
@@ -488,6 +493,10 @@ class ConfigUpdateController extends ControllerBase {
|
||||
'data' => $this->t('Type'),
|
||||
'class' => [RESPONSIVE_PRIORITY_MEDIUM],
|
||||
],
|
||||
'provider' => [
|
||||
'data' => $this->t('Provider'),
|
||||
'class' => [RESPONSIVE_PRIORITY_LOW],
|
||||
],
|
||||
'operations' => [
|
||||
'data' => $this->t('Operations'),
|
||||
],
|
||||
@@ -510,6 +519,7 @@ class ConfigUpdateController extends ControllerBase {
|
||||
if (!$entity_type) {
|
||||
// This is simple config.
|
||||
$id = $name;
|
||||
$label = '';
|
||||
$type_label = $this->t('Simple configuration');
|
||||
$entity_type = 'system.simple';
|
||||
}
|
||||
@@ -517,13 +527,57 @@ class ConfigUpdateController extends ControllerBase {
|
||||
$definition = $this->configList->getType($entity_type);
|
||||
$id_key = $definition->getKey('id');
|
||||
$id = $config[$id_key];
|
||||
// The label key is not required.
|
||||
if ($label_key = $definition->getKey('label')) {
|
||||
$label = $config[$label_key];
|
||||
}
|
||||
else {
|
||||
$label = '';
|
||||
}
|
||||
|
||||
$type_label = $definition->getLabel();
|
||||
}
|
||||
|
||||
$label = (isset($config['label'])) ? $config['label'] : '';
|
||||
$row[] = $name;
|
||||
$row[] = $label;
|
||||
$row[] = $type_label;
|
||||
$provider = $this->configList->getConfigProvider($name);
|
||||
$provider_name = '';
|
||||
if (!empty($provider)) {
|
||||
switch($provider[0]) {
|
||||
case 'profile':
|
||||
$provider_name = $this->moduleHandler->getName($provider[1]);
|
||||
if ($provider_name) {
|
||||
$provider_name = $this->t('@name profile', ['@name' => $provider_name]);
|
||||
}
|
||||
else {
|
||||
$provider_name = '';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'module':
|
||||
$provider_name = $this->moduleHandler->getName($provider[1]);
|
||||
if ($provider_name) {
|
||||
$provider_name = $this->t('@name module', ['@name' => $provider_name]);
|
||||
}
|
||||
else {
|
||||
$provider_name = '';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'theme':
|
||||
$provider_name = $this->themeHandler->getName($provider[1]);
|
||||
if ($provider_name) {
|
||||
$provider_name = $this->t('@name theme', ['@name' => $provider_name]);
|
||||
}
|
||||
else {
|
||||
$provider_name = '';
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$row[] = $provider_name;
|
||||
|
||||
$links = [];
|
||||
$routes = [
|
||||
|
||||
+198
-4
@@ -33,12 +33,17 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
parent::setUp();
|
||||
|
||||
// Create user and log in.
|
||||
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer search', 'view config updates report', 'synchronize configuration', 'export configuration', 'import configuration', 'revert configuration', 'delete configuration']);
|
||||
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer search', 'view config updates report', 'synchronize configuration', 'export configuration', 'import configuration', 'revert configuration', 'delete configuration', 'administer filters']);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Make sure local tasks and page title are showing.
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
|
||||
// Load the Drush include file so that its functions can be tested, plus
|
||||
// the Drush testing include file.
|
||||
module_load_include('inc', 'config_update_ui', 'config_update_ui.drush_testing');
|
||||
module_load_include('inc', 'config_update_ui', 'config_update_ui.drush');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,18 +55,33 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->clickLink('Updates report');
|
||||
$this->assertNoReport();
|
||||
|
||||
// Verify the Drush list types command.
|
||||
$output = implode("\n", drush_config_update_ui_config_list_types());
|
||||
$this->assertTrue(strpos($output, 'search_page') !== FALSE);
|
||||
$this->assertTrue(strpos($output, 'node_type') !== FALSE);
|
||||
$this->assertTrue(strpos($output, 'user_role') !== FALSE);
|
||||
$this->assertTrue(strpos($output, 'block') !== FALSE);
|
||||
|
||||
// Verify some empty reports.
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], []);
|
||||
$this->assertDrushReports('type', 'search_page', [], [], [], []);
|
||||
|
||||
// Module, theme, and profile reports have no 'added' section.
|
||||
$this->drupalGet('admin/config/development/configuration/report/module/search');
|
||||
$this->assertReport('Search module', [], [], [], [], ['added']);
|
||||
$this->assertDrushReports('module', 'search', [], [], [], []);
|
||||
$this->drupalGet('admin/config/development/configuration/report/theme/classy');
|
||||
$this->assertReport('Classy theme', [], [], [], [], ['added']);
|
||||
$this->assertDrushReports('theme', 'classy', [], [], [], []);
|
||||
|
||||
$inactive = ['locale.settings' => 'Simple configuration'];
|
||||
$this->drupalGet('admin/config/development/configuration/report/profile');
|
||||
$this->assertReport('Testing profile', [], [], [], $inactive, ['added']);
|
||||
// The locale.settings line should show that the Testing profile is the
|
||||
// provider.
|
||||
$this->assertText('Testing profile');
|
||||
$this->assertDrushReports('profile', '', [], [], [], array_keys($inactive));
|
||||
|
||||
// Delete the user search page from the search UI and verify report for
|
||||
// both the search page config type and user module.
|
||||
@@ -71,8 +91,15 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$inactive = ['search.page.user_search' => 'Users'];
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], $inactive);
|
||||
// The search.page.user_search line should show that the User module is the
|
||||
// provider.
|
||||
$this->assertText('User module');
|
||||
$this->assertDrushReports('type', 'search_page', [], [], [], array_keys($inactive));
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration/report/module/user');
|
||||
$this->assertReport('User module', [], [], [], $inactive, ['added', 'changed']);
|
||||
$this->assertDrushReports('module', 'user', [], [], [],
|
||||
['rdf.mapping.user.user', 'search.page.user_search', 'views.view.user_admin_people', 'views.view.who_s_new', 'views.view.who_s_online' ], ['changed']);
|
||||
|
||||
// Use the import link to get it back. Do this from the search page
|
||||
// report to make sure we are importing the right config.
|
||||
@@ -82,6 +109,23 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->assertNoReport();
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], []);
|
||||
$this->assertDrushReports('type', 'search_page', [], [], [], []);
|
||||
|
||||
// Verify that after import, there is no config hash generated.
|
||||
$this->drupalGet('admin/config/development/configuration/single/export/search_page/user_search');
|
||||
$this->assertText('id: user_search');
|
||||
$this->assertNoText('default_config_hash:');
|
||||
|
||||
// Test importing again, this time using the Drush import command.
|
||||
$this->drupalGet('admin/config/search/pages');
|
||||
$this->clickLink('Delete');
|
||||
$this->drupalPostForm(NULL, [], 'Delete');
|
||||
$inactive = ['search.page.user_search' => 'Users'];
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], $inactive);
|
||||
drush_config_update_ui_config_import_missing('search.page.user_search');
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], []);
|
||||
|
||||
// Edit the node search page from the search UI and verify report.
|
||||
$this->drupalGet('admin/config/search/pages');
|
||||
@@ -93,6 +137,7 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$changed = ['search.page.node_search' => 'New label'];
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], $changed, []);
|
||||
$this->assertDrushReports('type', 'search_page', [], [], array_keys($changed), []);
|
||||
|
||||
// Test the show differences link.
|
||||
$this->clickLink('Show differences');
|
||||
@@ -101,6 +146,13 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->assertText('node');
|
||||
$this->assertText('new_path');
|
||||
|
||||
// Test the show differences Drush command.
|
||||
$output = drush_config_update_ui_config_diff('search.page.node_search');
|
||||
$this->assertTrue(strpos($output, 'Content') !== FALSE);
|
||||
$this->assertTrue(strpos($output, 'New label') !== FALSE);
|
||||
$this->assertTrue(strpos($output, 'node') !== FALSE);
|
||||
$this->assertTrue(strpos($output, 'new_path') !== FALSE);
|
||||
|
||||
// Test the Back link.
|
||||
$this->clickLink("Back to 'Updates report' page.");
|
||||
$this->assertNoReport();
|
||||
@@ -114,6 +166,14 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->assertText('path: new_path');
|
||||
$this->assertText('search.page.node_search.yml');
|
||||
|
||||
// Grab the uuid and hash lines for the next test.
|
||||
$text = $this->getTextContent();
|
||||
$matches = [];
|
||||
preg_match('|^.*uuid:.*$|m', $text, $matches);
|
||||
$uuid_line = $matches[0];
|
||||
preg_match('|^.*default_config_hash:.*$|m', $text, $matches);
|
||||
$hash_line = $matches[0];
|
||||
|
||||
// Test reverting.
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->clickLink('Revert to source');
|
||||
@@ -125,18 +185,53 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], []);
|
||||
|
||||
// Verify that the uuid and hash keys were retained in the revert.
|
||||
$this->drupalGet('admin/config/development/configuration/single/export/search_page/node_search');
|
||||
$this->assertText('id: node_search');
|
||||
$this->assertText($uuid_line);
|
||||
$this->assertText($hash_line);
|
||||
|
||||
// Test reverting again, this time using Drush single revert command.
|
||||
$this->drupalGet('admin/config/search/pages');
|
||||
$this->clickLink('Edit');
|
||||
$this->drupalPostForm(NULL, [
|
||||
'label' => 'New label',
|
||||
'path' => 'new_path',
|
||||
], 'Save search page');
|
||||
$changed = ['search.page.node_search' => 'New label'];
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], $changed, []);
|
||||
drush_config_update_ui_config_revert('search.page.node_search');
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], []);
|
||||
|
||||
// Test reverting again, this time using Drush multiple revert command.
|
||||
$this->drupalGet('admin/config/search/pages');
|
||||
$this->clickLink('Edit');
|
||||
$this->drupalPostForm(NULL, [
|
||||
'label' => 'New label',
|
||||
'path' => 'new_path',
|
||||
], 'Save search page');
|
||||
$changed = ['search.page.node_search' => 'New label'];
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], $changed, []);
|
||||
drush_config_update_ui_config_revert_multiple('type', 'search_page');
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], []);
|
||||
|
||||
// Add a new search page from the search UI and verify report.
|
||||
$this->drupalPostForm('admin/config/search/pages', [
|
||||
'search_type' => 'node_search',
|
||||
], 'Add new page');
|
||||
], 'Add search page');
|
||||
$this->drupalPostForm(NULL, [
|
||||
'label' => 'test',
|
||||
'id' => 'test',
|
||||
'path' => 'test',
|
||||
], 'Add search page');
|
||||
], 'Save');
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$added = ['search.page.test' => 'test'];
|
||||
$this->assertReport('Search page', [], $added, [], []);
|
||||
$this->assertDrushReports('type', 'search_page', [], array_keys($added), [], []);
|
||||
|
||||
// Test the export link.
|
||||
$this->clickLink('Export');
|
||||
@@ -174,13 +269,31 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->drupalGet('admin/config/development/configuration/report/module/search');
|
||||
$this->clickLink('Export');
|
||||
$this->assertText('minimum_word_size: 4');
|
||||
// Grab the hash line for the next test.
|
||||
$text = $this->getTextContent();
|
||||
$matches = [];
|
||||
preg_match('|^.*default_config_hash:.*$|m', $text, $matches);
|
||||
$hash_line = $matches[0];
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration/report/module/search');
|
||||
$this->clickLink('Revert to source');
|
||||
$this->drupalPostForm(NULL, [], 'Revert');
|
||||
|
||||
// Verify that the hash was retained in the revert.
|
||||
$this->drupalGet('admin/config/development/configuration/single/export/system.simple/search.settings');
|
||||
$this->assertText($hash_line);
|
||||
|
||||
$this->drupalGet('admin/config/development/configuration/report/module/search');
|
||||
$this->assertReport('Search module', [], [], [], [], ['added']);
|
||||
|
||||
// Edit the plain_text filter from the filter UI and verify report.
|
||||
// The filter_format config type uses a label key other than 'label'.
|
||||
$this->drupalPostForm('admin/config/content/formats/manage/plain_text', [
|
||||
'name' => 'New label',
|
||||
], 'Save configuration');
|
||||
$changed = ['filter.format.plain_text' => 'New label'];
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/filter_format');
|
||||
$this->assertReport('Text format', [], [], $changed, []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +306,7 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
* @param string[] $missing
|
||||
* Array of items that should be listed as missing, name => label.
|
||||
* @param string[] $added
|
||||
* Array of items that should be listed as missing, name => label.
|
||||
* Array of items that should be listed as added, name => label.
|
||||
* @param string[] $changed
|
||||
* Array of items that should be listed as changed, name => label.
|
||||
* @param string[] $inactive
|
||||
@@ -262,6 +375,66 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the Drush reports have the correct content.
|
||||
*
|
||||
* @param string $type
|
||||
* Type of report to run (type, module, theme, etc.).
|
||||
* @param string $name
|
||||
* Name of that type to run (e.g., module machine name).
|
||||
* @param string[] $missing
|
||||
* Array of config items that should be listed as missing.
|
||||
* @param string[] $added
|
||||
* Array of config items that should be listed as added.
|
||||
* @param string[] $changed
|
||||
* Array of config items that should be listed as changed.
|
||||
* @param string[] $inactive
|
||||
* Array of config items that should be listed as inactive.
|
||||
* @param string[] $skip
|
||||
* Array of report sections to skip checking.
|
||||
*/
|
||||
protected function assertDrushReports($type, $name, $missing, $added, $changed, $inactive, $skip = []) {
|
||||
if (!in_array('missing', $skip)) {
|
||||
$output = drush_config_update_ui_config_missing_report($type, $name);
|
||||
$this->assertEqual(count($output), count($missing), 'Drush missing report has correct number of items');
|
||||
if (count($missing)) {
|
||||
foreach ($missing as $item) {
|
||||
$this->assertTrue(in_array($item, $output), "Item $item is in the Drush missing report");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('added', $skip) && $type == 'type') {
|
||||
$output = drush_config_update_ui_config_added_report($name);
|
||||
$this->assertEqual(count($output), count($added), 'Drush added report has correct number of items');
|
||||
if (count($added)) {
|
||||
foreach ($added as $item) {
|
||||
$this->assertTrue(in_array($item, $output), "Item $item is in the Drush added report");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('changed', $skip)) {
|
||||
$output = drush_config_update_ui_config_different_report($type, $name);
|
||||
$this->assertEqual(count($output), count($changed), 'Drush changed report has correct number of items');
|
||||
if (count($changed)) {
|
||||
foreach ($changed as $item) {
|
||||
$this->assertTrue(in_array($item, $output), "Item $item is in the Drush changed report");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('inactive', $skip)) {
|
||||
$output = drush_config_update_ui_config_inactive_report($type, $name);
|
||||
$this->assertEqual(count($output), count($inactive), 'Drush inactive report has correct number of items');
|
||||
if (count($inactive)) {
|
||||
foreach ($inactive as $item) {
|
||||
$this->assertTrue(in_array($item, $output), "Item $item is in the Drush inactive report");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the report is not shown.
|
||||
*
|
||||
@@ -278,6 +451,27 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->assertNoText('Added configuration items');
|
||||
$this->assertNoText('Changed configuration items');
|
||||
$this->assertNoText('Unchanged configuration items');
|
||||
|
||||
// Verify that certain report links are shown or not shown. For extensions,
|
||||
// only extensions that have configuration should be shown.
|
||||
|
||||
// Modules.
|
||||
$this->assertLink('Search');
|
||||
$this->assertLink('Field');
|
||||
$this->assertNoLink('Configuration Update Base');
|
||||
$this->assertNoLink('Configuration Update Reports');
|
||||
|
||||
// Themes.
|
||||
$this->assertNoLink('Stark');
|
||||
$this->assertNoLink('Classy');
|
||||
|
||||
// Profiles.
|
||||
$this->assertLink('Testing');
|
||||
|
||||
// Configuration types.
|
||||
$this->assertLink('All types');
|
||||
$this->assertLink('Simple configuration');
|
||||
$this->assertLink('Search page');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,6 +76,10 @@ class ConfigDiffer implements ConfigDiffInterface {
|
||||
* @see ConfigDiffer::$ignore
|
||||
*/
|
||||
protected function normalize($config) {
|
||||
if (empty($config)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Remove "ignore" elements.
|
||||
foreach ($this->ignore as $element) {
|
||||
unset($config[$element]);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\config_update;
|
||||
|
||||
/**
|
||||
* Defines an extended interface for listing configuration.
|
||||
*/
|
||||
interface ConfigListByProviderInterface extends ConfigListInterface {
|
||||
|
||||
/**
|
||||
* Returns the provider of a given config object.
|
||||
*
|
||||
* @param string $name
|
||||
* Name of the config object.
|
||||
*
|
||||
* @return string[]
|
||||
* Array containing the type of extension providing this config object as
|
||||
* its first element (module, theme, profile), and the name of the provider
|
||||
* as its second element. NULL if unknown.
|
||||
*/
|
||||
public function getConfigProvider($name);
|
||||
|
||||
/**
|
||||
* Lists the providers of a given type that actually have configuration.
|
||||
*
|
||||
* @param string $type
|
||||
* Type of extension (module, theme, profile).
|
||||
* @param string $name
|
||||
* Machine name of extension.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the extension has either install or optional config, and FALSE
|
||||
* if it does not.
|
||||
*/
|
||||
public function providerHasConfig($type, $name);
|
||||
|
||||
}
|
||||
@@ -38,13 +38,13 @@ interface ConfigListInterface {
|
||||
public function getTypeByPrefix($prefix);
|
||||
|
||||
/**
|
||||
* Returns the entity type object for a given config object.
|
||||
* Returns the config type name for a given config object.
|
||||
*
|
||||
* @param string $name
|
||||
* Name of the config object.
|
||||
*
|
||||
* @return string
|
||||
* Name of the entity type that this is an instance of, determined by
|
||||
* Name of the config type that this is an instance of, determined by
|
||||
* prefix. NULL for simple configuration.
|
||||
*/
|
||||
public function getTypeNameByConfigName($name);
|
||||
|
||||
@@ -82,10 +82,12 @@ class ConfigLister implements ConfigListInterface {
|
||||
* Sets up and returns the entity definitions list.
|
||||
*/
|
||||
public function listTypes() {
|
||||
// Return list if it has already been calculated.
|
||||
if (count($this->definitions)) {
|
||||
return $this->definitions;
|
||||
}
|
||||
|
||||
// Calculate and return the list.
|
||||
foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) {
|
||||
if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) {
|
||||
$this->definitions[$entity_type] = $definition;
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\config_update;
|
||||
|
||||
use Drupal\Core\Config\ExtensionInstallStorage;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Extension\ThemeHandlerInterface;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
|
||||
/**
|
||||
* Provides methods related to config listing, including provider calculation.
|
||||
*/
|
||||
class ConfigListerWithProviders extends ConfigLister implements ConfigListByProviderInterface {
|
||||
|
||||
/**
|
||||
* List of providers of config, keyed by config item name.
|
||||
*
|
||||
* The array elements are each arrays, with the type of extension providing
|
||||
* the config object as the first element (module, theme, profile), and the
|
||||
* name of the provider as the second element.
|
||||
*
|
||||
* This is not set up until ConfigListerWithProviders::listProviders() has
|
||||
* been called.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $providers = [];
|
||||
|
||||
/**
|
||||
* List of extensions that provide configuration, keyed by type.
|
||||
*
|
||||
* This is not set up until ConfigListerWithProviders::listProviders() has
|
||||
* been called.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $extensionsWithConfig = [];
|
||||
|
||||
/**
|
||||
* The module handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* The theme handler.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ThemeHandlerInterface
|
||||
*/
|
||||
protected $themeHandler;
|
||||
|
||||
/**
|
||||
* Constructs a ConfigListerWithProviders.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Config\StorageInterface $active_config_storage
|
||||
* The active config storage.
|
||||
* @param \Drupal\Core\Config\ExtensionInstallStorage $extension_config_storage
|
||||
* The extension config storage.
|
||||
* @param \Drupal\Core\Config\ExtensionInstallStorage $extension_optional_config_storage
|
||||
* The extension config storage for optional config items.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
|
||||
* The theme handler.
|
||||
*/
|
||||
public function __construct(EntityTypeManagerInterface $entity_manager, StorageInterface $active_config_storage, ExtensionInstallStorage $extension_config_storage, ExtensionInstallStorage $extension_optional_config_storage, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->activeConfigStorage = $active_config_storage;
|
||||
$this->extensionConfigStorage = $extension_config_storage;
|
||||
$this->extensionOptionalConfigStorage = $extension_optional_config_storage;
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->themeHandler = $theme_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up and returns the config providers list.
|
||||
*/
|
||||
public function listProviders() {
|
||||
// Return the list if it has already been set up.
|
||||
if (count($this->providers)) {
|
||||
return $this->providers;
|
||||
}
|
||||
|
||||
// Calculate if it hasn't been set up yet.
|
||||
|
||||
// List all of the profile, modules, and themes.
|
||||
$extensionsToDo = [];
|
||||
$profile = Settings::get('install_profile');
|
||||
$extensionsToDo[] = ['profile', $profile];
|
||||
|
||||
$modules = $this->moduleHandler->getModuleList();
|
||||
foreach ($modules as $machine_name => $module) {
|
||||
if ($machine_name != $profile) {
|
||||
$extensionsToDo[] = ['module', $machine_name];
|
||||
}
|
||||
}
|
||||
|
||||
$themes = $this->themeHandler->listInfo();
|
||||
foreach ($themes as $machine_name => $theme) {
|
||||
$extensionsToDo[] = ['theme', $machine_name];
|
||||
}
|
||||
|
||||
// For each extension, figure out if it has config, and make an index of
|
||||
// config item => provider.
|
||||
$this->extensionsWithConfig = [
|
||||
'profile' => [],
|
||||
'module' => [],
|
||||
'theme' => [],
|
||||
];
|
||||
|
||||
foreach($extensionsToDo as $item) {
|
||||
$type = $item[0];
|
||||
$name = $item[1];
|
||||
$configs = array_merge($this->listProvidedItems($type, $name),
|
||||
$this->listProvidedItems($type, $name, TRUE));
|
||||
if (!empty($configs)) {
|
||||
$this->extensionsWithConfig[$type][$name] = $name;
|
||||
foreach($configs as $config) {
|
||||
$this->providers[$config] = [$type, $name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigProvider($name) {
|
||||
$providers = $this->listProviders();
|
||||
|
||||
return (isset($providers[$name])) ? $providers[$name] : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerHasConfig($type, $name) {
|
||||
// Make sure the list of extensions with configuration has been generated.
|
||||
$this->listProviders();
|
||||
|
||||
return isset($this->extensionsWithConfig[$type][$name]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -129,21 +129,25 @@ class ConfigReverter implements ConfigRevertInterface, ConfigDeleteInterface {
|
||||
}
|
||||
|
||||
if ($type == 'system.simple') {
|
||||
// Load the current config and replace the value.
|
||||
$this->configFactory->getEditable($full_name)->setData($value)->save();
|
||||
// Load the current config and replace the value, retaining the config
|
||||
// hash (which is part of the _core config key's value).
|
||||
$config = $this->configFactory->getEditable($full_name);
|
||||
$core = $config->get('_core');
|
||||
$config->setData($value);
|
||||
$config->set('_core', $core);
|
||||
$config->save();
|
||||
}
|
||||
else {
|
||||
// Load the current config entity and replace the value, with the
|
||||
// old UUID.
|
||||
// Load the current config entity and replace the value. Note that
|
||||
// the uuid and _core/hash values are retained for entity-based config,
|
||||
// since updateFromStorageRecord() only updates values that are part of
|
||||
// the passed-in array, and doesn't remove or alter other values.
|
||||
$definition = $this->entityManager->getDefinition($type);
|
||||
$id_key = $definition->getKey('id');
|
||||
|
||||
$id = $value[$id_key];
|
||||
$entity_storage = $this->entityManager->getStorage($type);
|
||||
$entity = $entity_storage->load($id);
|
||||
$uuid = $entity->get('uuid');
|
||||
$entity = $entity_storage->updateFromStorageRecord($entity, $value);
|
||||
$entity->set('uuid', $uuid);
|
||||
$entity->save();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user