|
8 | 8 | use Statamic\Console\RunsInPlease; |
9 | 9 | use Statamic\Contracts\Globals\GlobalRepository as GlobalRepositoryContract; |
10 | 10 | use Statamic\Contracts\Globals\GlobalSet as GlobalSetContract; |
| 11 | +use Statamic\Contracts\Globals\GlobalVariablesRepository as GlobalVariablesRepositoryContract; |
| 12 | +use Statamic\Contracts\Globals\Variables as VariablesContract; |
11 | 13 | use Statamic\Eloquent\Globals\GlobalSetModel; |
| 14 | +use Statamic\Eloquent\Globals\VariablesModel; |
12 | 15 | use Statamic\Facades\GlobalSet as GlobalSetFacade; |
13 | 16 | use Statamic\Globals\GlobalSet; |
| 17 | +use Statamic\Globals\Variables; |
14 | 18 | use Statamic\Stache\Repositories\GlobalRepository; |
| 19 | +use Statamic\Stache\Repositories\GlobalVariablesRepository; |
15 | 20 | use Statamic\Statamic; |
16 | 21 |
|
17 | 22 | class ExportGlobals extends Command |
@@ -49,25 +54,29 @@ public function handle() |
49 | 54 | private function usingDefaultRepositories(Closure $callback) |
50 | 55 | { |
51 | 56 | Facade::clearResolvedInstance(GlobalRepositoryContract::class); |
| 57 | + Facade::clearResolvedInstance(GlobalVariablesRepositoryContract::class); |
52 | 58 |
|
53 | 59 | Statamic::repository(GlobalRepositoryContract::class, GlobalRepository::class); |
| 60 | + Statamic::repository(GlobalVariablesRepositoryContract::class, GlobalVariablesRepository::class); |
54 | 61 |
|
55 | 62 | app()->bind(GlobalSetContract::class, GlobalSet::class); |
| 63 | + app()->bind(VariablesContract::class, Variables::class); |
56 | 64 |
|
57 | 65 | $callback(); |
58 | 66 | } |
59 | 67 |
|
60 | 68 | private function exportGlobals() |
61 | 69 | { |
62 | 70 | $sets = GlobalSetModel::all(); |
| 71 | + $variables = VariablesModel::all(); |
63 | 72 |
|
64 | | - $this->withProgressBar($sets, function ($model) { |
| 73 | + $this->withProgressBar($sets, function ($model) use ($variables) { |
65 | 74 | $global = GlobalSetFacade::make() |
66 | 75 | ->handle($model->handle) |
67 | 76 | ->title($model->title) |
68 | 77 | ->save(); |
69 | 78 |
|
70 | | - foreach ($model->localizations as $localization) { |
| 79 | + foreach ($variables->where('handle', $model->handle) as $localization) { |
71 | 80 | $global->makeLocalization($localization->locale) |
72 | 81 | ->data($localization->data) |
73 | 82 | ->origin($localization->origin ?? null) |
|
0 commit comments