Skip to content
Snippets Groups Projects

Resolve #3508419 "Support glob style"

@@ -62,7 +62,8 @@ class InspectorCommands extends DrushCommands {
* @option skip-keys
* Configuration keys to skip. Cannot be used together with filter-keys.
* @option filter-keys
* Configuration keys to filter. Cannot be used together with skip-keys.
* Configuration keys to filter. Supports glob style patterns. Cannot be
* used together with skip-keys.
* @option strict-validation
* Treat <100% validatability as an error.
* @option list-constraints
@@ -85,6 +86,9 @@ class InspectorCommands extends DrushCommands {
* @usage drush config:inspect --only-error --strict-validation --filter-keys=media.settings,system.theme.global
* Inspect only media.settings and system.theme.global config for schema and
* validatability errors.
* @usage drush config:inspect --only-error --strict-validation --filter-keys=system.action.*
* Inspect all items matching system.action.* for schema and validatability
* errors.
*
* @field-labels
* key: Key
@@ -141,6 +145,9 @@ class InspectorCommands extends DrushCommands {
$strict_validation = $options['strict-validation'];
$skipKeys = !isset($options['skip-keys']) ? [] : array_fill_keys(explode(',', $options['skip-keys']), '1');
$filterKeys = !isset($options['filter-keys']) ? [] : array_fill_keys(explode(',', $options['filter-keys']), '1');
$filterKeysHasWildcards = isset($options['filter-keys']) && ((str_contains($options['filter-keys'], '*') || str_contains($options['filter-keys'], '?')));
$listConstraints = $options['list-constraints'];
$total_raw_validatability = NULL;
@@ -155,9 +162,18 @@ class InspectorCommands extends DrushCommands {
if (isset($skipKeys[$name])) {
continue;
}
if (!empty($filterKeys) && !isset($filterKeys[$name])) {
if (!empty($filterKeys) && $filterKeysHasWildcards === FALSE && !isset($filterKeys[$name])) {
continue;
}
if (!empty($filterKeys) && $filterKeysHasWildcards === TRUE) {
// @phpcs:disable Drupal.Functions.DiscouragedFunctions.Discouraged
$filterKeysMatched = array_filter($filterKeys, fn ($filterKey) => fnmatch($filterKey, $name), ARRAY_FILTER_USE_KEY);
// phpcs:enable
if (empty($filterKeysMatched)) {
continue;
}
}
$has_schema = $this->inspector->hasSchema($name);
if (!$has_schema) {
$status = dt('No schema');
Loading