-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
…when translation are not used in model
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace Sevendays\FilamentPageBuilder; | ||
|
||
use Filament\Facades\Filament; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Filesystem\Filesystem; | ||
use Illuminate\Support\Str; | ||
|
@@ -32,7 +33,7 @@ public function getAllBlocks(): array | |
return []; | ||
} | ||
|
||
$namespace = Str::of(config('filament.resources.namespace'))->beforeLast('\\')->append('\\Blocks*'); | ||
$namespace = Str::of(Filament::getCurrentPanel()->getResourceNamespaces()[0])->beforeLast('\\')->append('\\Blocks*'); | ||
|
||
$classes = collect($this->filesystem->allFiles($blocksDirectory)) | ||
->map(function (SplFileInfo $file) use ($namespace) { | ||
|
@@ -66,7 +67,12 @@ public function renderBlock(Block $block): string|View | |
{ | ||
/** @var class-string<BlockEditorBlock> $class */ | ||
if ($class = ($this->getAllBlocks()[$block->type] ?? false)) { | ||
Check failure on line 69 in src/BlockRenderer.php GitHub Actions / phpstan
Check failure on line 69 in src/BlockRenderer.php GitHub Actions / phpstan
Check failure on line 69 in src/BlockRenderer.php GitHub Actions / phpstan
Check failure on line 69 in src/BlockRenderer.php GitHub Actions / phpstan
|
||
$content = is_array($block->shared) ? [...$block->content, ...$block->shared] : $block->content; | ||
$pageContent = $block->content; | ||
Check failure on line 70 in src/BlockRenderer.php GitHub Actions / phpstan
|
||
//todo dirty hack to 'detect' if translations are in use ... | ||
if($block->content === ''){ | ||
Check failure on line 72 in src/BlockRenderer.php GitHub Actions / phpstan
|
||
$pageContent = $block->translations['content']; | ||
Check failure on line 73 in src/BlockRenderer.php GitHub Actions / phpstan
|
||
} | ||
$content = is_array($block->shared) ? [...$pageContent, ...$block->shared] : $pageContent; | ||
Check failure on line 75 in src/BlockRenderer.php GitHub Actions / phpstan
|
||
|
||
return $class::make($block->type)->renderDisplay($content); | ||
Check failure on line 77 in src/BlockRenderer.php GitHub Actions / phpstan
|
||
} | ||
|