Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Taxonomy export arguments, matching import #393

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/Commands/ExportTaxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class ExportTaxonomies extends Command
*
* @var string
*/
protected $signature = 'statamic:eloquent:export-taxonomies {--force : Force the export to run, with all prompts answered "yes"}';
protected $signature = 'statamic:eloquent:export-taxonomies
{--force : Force the export to run, with all prompts answered "yes"}
{--only-taxonomies : Only export taxonomies}
{--only-terms : Only export terms}';

/**
* The console command description.
Expand Down Expand Up @@ -69,7 +72,7 @@ private function usingDefaultRepositories(Closure $callback)

private function exportTaxonomies()
{
if (! $this->option('force') && ! $this->confirm('Do you want to export taxonomies?')) {
if (! $this->shouldExportTaxonomies()) {
return;
}

Expand All @@ -90,7 +93,7 @@ private function exportTaxonomies()

private function exportTerms()
{
if (! $this->option('force') && ! $this->confirm('Do you want to export terms?')) {
if (! $this->shouldExportTerms()) {
return;
}

Expand Down Expand Up @@ -130,4 +133,18 @@ private function exportTerms()
$this->newLine();
$this->info('Terms exported');
}

private function shouldExportTaxonomies(): bool
{
return $this->option('only-taxonomies')
|| ! $this->option('only-terms')
&& ($this->option('force') || $this->confirm('Do you want to export taxonomies?'));
}

private function shouldExportTerms(): bool
{
return $this->option('only-terms')
|| ! $this->option('only-taxonomies')
&& ($this->option('force') || $this->confirm('Do you want to export terms?'));
}
}
Loading