Skip to content

Commit

Permalink
Allow developers to add repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Feb 6, 2025
1 parent 970ee2b commit 8f0af57
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Console/Commands/InstallEloquentDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class InstallEloquentDriver extends Command
*/
protected $description = "Install & configure Statamic's Eloquent Driver package";

protected static array $additionalRepositories = [];

/**
* Execute the console command.
*
Expand Down Expand Up @@ -124,6 +126,11 @@ protected function repositories(): array
);
}

public static function addRepository(string $key, array $config): void
{
self::$additionalRepositories[$key] = $config;
}

protected function allRepositories(): Collection
{
return collect([
Expand All @@ -145,7 +152,9 @@ protected function allRepositories(): Collection
'taxonomies' => 'Taxonomies',
'terms' => 'Terms',
'tokens' => 'Tokens',
]);
])
->merge(Arr::map(self::$additionalRepositories, fn ($value) => $value['title']))
->sort();
}

protected function repositoryHasBeenMigrated(string $repository): bool
Expand Down Expand Up @@ -205,6 +214,9 @@ protected function repositoryHasBeenMigrated(string $repository): bool

case 'tokens':
return config('statamic.eloquent-driver.tokens.driver') === 'eloquent';

case $repository:
return Arr::get(self::$additionalRepositories, "{$repository}.hasBeenMigrated");
}
}

Expand Down

0 comments on commit 8f0af57

Please sign in to comment.