Skip to content

Commit

Permalink
project-config/apply --quiet
Browse files Browse the repository at this point in the history
Resolves #12568
  • Loading branch information
brandonkelly committed Feb 2, 2023
1 parent 44b2c8b commit d046377
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Conditional layout components are now identified using a condition icon within field layout designers. ([#12250](https://github.com/craftcms/cms/issues/12250))
- All CLI commands now support an `--isolated` option, which ensures the command is run in isolation. ([#12337](https://github.com/craftcms/cms/discussions/12337), [#12350](https://github.com/craftcms/cms/pull/12350))
- The `plugin/install`, `plugin/uninstall`, `plugin/enable`, and `plugin/disabled` commands now support an `--all` option, which applies the action to all applicable Composer-installed plugins. ([#11373](https://github.com/craftcms/cms/discussions/11373), [#12218](https://github.com/craftcms/cms/pull/12218))
- The `project-config/apply` command now supports a `--quiet` option, which reduces the command output. ([#12568](https://github.com/craftcms/cms/discussions/12568))
- Added the `users/unlock` console command. ([#12345](https://github.com/craftcms/cms/discussions/12345))

### Development
Expand Down
25 changes: 17 additions & 8 deletions src/console/controllers/ProjectConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ class ProjectConfigController extends Controller
*/
public bool $force = false;

/**
* @var bool Whether to reduce the command output.
* @since 4.4.0
*/
public bool $quiet = false;

/**
* @var bool Whether to treat the loaded project config as the source of truth, instead of the YAML files.
* @since 3.5.13
Expand Down Expand Up @@ -90,6 +96,7 @@ public function options($actionID): array
case 'apply':
case 'sync':
$options[] = 'force';
$options[] = 'quiet';
break;
case 'diff':
$options[] = 'invert';
Expand Down Expand Up @@ -291,14 +298,16 @@ public function actionApply(): int
try {
$forceUpdate = $projectConfig->forceUpdate;
$projectConfig->forceUpdate = $this->force;
$this->_processingPaths = [];

$projectConfig->on(ProjectConfigService::EVENT_ADD_ITEM, [$this, 'onStartProcessingItem'], ['label' => 'adding'], false);
$projectConfig->on(ProjectConfigService::EVENT_ADD_ITEM, [$this, 'onFinishProcessingItem'], ['label' => 'adding'], true);
$projectConfig->on(ProjectConfigService::EVENT_REMOVE_ITEM, [$this, 'onStartProcessingItem'], ['label' => 'removing'], false);
$projectConfig->on(ProjectConfigService::EVENT_REMOVE_ITEM, [$this, 'onFinishProcessingItem'], ['label' => 'removing'], true);
$projectConfig->on(ProjectConfigService::EVENT_UPDATE_ITEM, [$this, 'onStartProcessingItem'], ['label' => 'updating'], false);
$projectConfig->on(ProjectConfigService::EVENT_UPDATE_ITEM, [$this, 'onFinishProcessingItem'], ['label' => 'updating'], true);

if (!$this->quiet) {
$this->_processingPaths = [];
$projectConfig->on(ProjectConfigService::EVENT_ADD_ITEM, [$this, 'onStartProcessingItem'], ['label' => 'adding'], false);
$projectConfig->on(ProjectConfigService::EVENT_ADD_ITEM, [$this, 'onFinishProcessingItem'], ['label' => 'adding'], true);
$projectConfig->on(ProjectConfigService::EVENT_REMOVE_ITEM, [$this, 'onStartProcessingItem'], ['label' => 'removing'], false);
$projectConfig->on(ProjectConfigService::EVENT_REMOVE_ITEM, [$this, 'onFinishProcessingItem'], ['label' => 'removing'], true);
$projectConfig->on(ProjectConfigService::EVENT_UPDATE_ITEM, [$this, 'onStartProcessingItem'], ['label' => 'updating'], false);
$projectConfig->on(ProjectConfigService::EVENT_UPDATE_ITEM, [$this, 'onFinishProcessingItem'], ['label' => 'updating'], true);
}

$projectConfig->applyExternalChanges();

Expand Down

0 comments on commit d046377

Please sign in to comment.