Skip to content

Commit

Permalink
Corrects issue with importing/exporting Blueprints on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnathonKoster committed Sep 9, 2024
1 parent 8111023 commit 6c0c32b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Commands/ExportBlueprints.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Facade;
use Statamic\Console\RunsInPlease;
use Statamic\Eloquent\Fields\Blueprint as StacheBlueprint;
use Statamic\Eloquent\Fields\BlueprintModel;
use Statamic\Eloquent\Fields\FieldsetModel;
use Statamic\Fields\Blueprint as StacheBlueprint;
use Statamic\Fields\Fieldset as StacheFieldset;
use Statamic\Support\Arr;

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ImportBlueprints.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function importBlueprints(): void
return;
}

$directory = resource_path('blueprints');
$directory = str_replace('\\', '/', resource_path('blueprints'));

$files = File::withAbsolutePaths()
->getFilesByTypeRecursively($directory, 'yaml');
Expand Down
21 changes: 21 additions & 0 deletions src/Fields/Blueprint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Statamic\Eloquent\Fields;

use Statamic\Fields\Blueprint as CoreBlueprint;
use Statamic\Support\Str;

class Blueprint extends CoreBlueprint
{
public function namespace(): ?string
{
$blueprintDir = str_replace('\\', '/', \Statamic\Facades\Blueprint::directory());
$blueprintDir = str_replace('/', '.', $blueprintDir);

if (Str::startsWith($this->namespace, $blueprintDir)) {
return mb_substr($this->namespace, mb_strlen($blueprintDir));
}

return $this->namespace;
}
}

0 comments on commit 6c0c32b

Please sign in to comment.