updated core and modules
This commit is contained in:
@@ -267,11 +267,14 @@ function drush_features_list_packages($package_name = '') {
|
||||
*
|
||||
*/
|
||||
function drush_features_import_all() {
|
||||
_drush_features_options();
|
||||
$assigner = _drush_features_options();
|
||||
$current_bundle = $assigner->getBundle();
|
||||
$namespace = $current_bundle->isDefault() ? '' : $current_bundle->getMachineName();
|
||||
|
||||
/** @var \Drupal\features\FeaturesManagerInterface $manager */
|
||||
$manager = \Drupal::service('features.manager');
|
||||
$packages = $manager->getPackages();
|
||||
$packages = $manager->filterPackages($packages);
|
||||
$packages = $manager->filterPackages($packages, $namespace);
|
||||
$overridden = array();
|
||||
|
||||
foreach ($packages as $package) {
|
||||
@@ -491,7 +494,7 @@ function drush_features_diff() {
|
||||
$filter_ctypes = explode(',', $filter_ctypes);
|
||||
}
|
||||
|
||||
$feature = _drush_features_load_feature($module, TRUE);
|
||||
$feature = $manager->loadPackage($module, TRUE);
|
||||
if (empty($feature)) {
|
||||
drush_log(dt('No such feature is available: @module', array('@module' => $module)), 'error');
|
||||
return;
|
||||
@@ -583,8 +586,6 @@ function drush_features_import() {
|
||||
|
||||
/** @var \Drupal\features\FeaturesManagerInterface $manager */
|
||||
$manager = \Drupal::service('features.manager');
|
||||
/** @var \Drupal\config_update\ConfigRevertInterface $config_revert */
|
||||
$config_revert = \Drupal::service('features.config_update');
|
||||
|
||||
// Parse list of arguments.
|
||||
$modules = array();
|
||||
@@ -613,7 +614,7 @@ function drush_features_import() {
|
||||
|
||||
$dt_args['@module'] = $module;
|
||||
/** @var \Drupal\features\Package $feature */
|
||||
$feature = _drush_features_load_feature($module, TRUE);
|
||||
$feature = $manager->loadPackage($module, TRUE);
|
||||
if (empty($feature)) {
|
||||
drush_log(dt('No such feature is available: @module', $dt_args), 'error');
|
||||
return;
|
||||
@@ -644,30 +645,33 @@ function drush_features_import() {
|
||||
drush_log(dt('Current state already matches active config, aborting.'), 'ok');
|
||||
}
|
||||
else {
|
||||
$config = $manager->getConfigCollection();
|
||||
// Determine which config the user wants to import/revert.
|
||||
$config_to_create = [];
|
||||
foreach ($components as $component) {
|
||||
$dt_args['@component'] = $component;
|
||||
$confirmation_message = 'Do you really want to import @module : @component?';
|
||||
if ($skip_confirmation || drush_confirm(dt($confirmation_message, $dt_args))) {
|
||||
if (!isset($config[$component])) {
|
||||
// Import missing component.
|
||||
/** @var array $item */
|
||||
$item = $manager->getConfigType($component);
|
||||
$type = ConfigurationItem::fromConfigStringToConfigType($item['type']);
|
||||
$config_revert->import($type, $item['name_short']);
|
||||
drush_log(dt('Import @module : @component.', $dt_args), 'ok');
|
||||
}
|
||||
else {
|
||||
// Revert existing component.
|
||||
/** @var \Drupal\features\ConfigurationItem $item */
|
||||
$item = $config[$component];
|
||||
$type = ConfigurationItem::fromConfigStringToConfigType($item->getType());
|
||||
$config_revert->revert($type, $item->getShortName());
|
||||
drush_log(dt('Reverted @module : @component.', $dt_args), 'ok');
|
||||
}
|
||||
$config_to_create[$component] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the import/revert.
|
||||
$config_imported = $manager->createConfiguration($config_to_create);
|
||||
|
||||
// List the results.
|
||||
foreach ($components as $component) {
|
||||
$dt_args['@component'] = $component;
|
||||
if (isset($config_imported['new'][$component])) {
|
||||
drush_log(dt('Imported @module : @component.', $dt_args), 'ok');
|
||||
}
|
||||
elseif (isset($config_imported['updated'][$component])) {
|
||||
drush_log(dt('Reverted @module : @component.', $dt_args), 'ok');
|
||||
}
|
||||
elseif (!isset($config_to_create[$component])) {
|
||||
drush_log(dt('Skipping @module : @component.', $dt_args), 'ok');
|
||||
}
|
||||
else {
|
||||
drush_log(dt('Skipping @module : @component.', $dt_args), 'ok');
|
||||
drush_log(dt('Error importing @module : @component.', $dt_args), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -679,35 +683,6 @@ function drush_features_import() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a Features package.
|
||||
*
|
||||
* @param string $module
|
||||
* The machine name of a module.
|
||||
* @param bool $any
|
||||
* If TRUE then check for any module, not just a Features module.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function _drush_features_load_feature($module, $any = FALSE) {
|
||||
/** @var \Drupal\features\FeaturesManagerInterface $manager */
|
||||
$manager = \Drupal::service('features.manager');
|
||||
$feature = $manager->getPackage($module);
|
||||
if ($any && !isset($feature)) {
|
||||
// See if this is a non-features module.
|
||||
$module_handler = \Drupal::moduleHandler();
|
||||
$modules = $module_handler->getModuleList();
|
||||
if (!empty($modules[$module])) {
|
||||
$extension = $modules[$module];
|
||||
$feature = $manager->initPackageFromExtension($extension);
|
||||
$config = $manager->listExtensionConfig($extension);
|
||||
$feature->setConfig($config);
|
||||
$feature->setStatus(FeaturesManagerInterface::STATUS_INSTALLED);
|
||||
}
|
||||
}
|
||||
return $feature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of full config names given a array[$type][$component].
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user