From 933c3a914a2f42e5adf319ca8126cb1069c59520 Mon Sep 17 00:00:00 2001 From: John Koster Date: Sat, 26 Oct 2024 21:34:32 -0500 Subject: [PATCH] Initial commit --- config/templates.php | 5 +++++ .../ScaffoldCollectionController.php | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 config/templates.php diff --git a/config/templates.php b/config/templates.php new file mode 100644 index 0000000000..6cba474c01 --- /dev/null +++ b/config/templates.php @@ -0,0 +1,5 @@ + 'antlers', +]; diff --git a/src/Http/Controllers/CP/Collections/ScaffoldCollectionController.php b/src/Http/Controllers/CP/Collections/ScaffoldCollectionController.php index e28cd4d751..7ea99de57a 100644 --- a/src/Http/Controllers/CP/Collections/ScaffoldCollectionController.php +++ b/src/Http/Controllers/CP/Collections/ScaffoldCollectionController.php @@ -3,12 +3,18 @@ namespace Statamic\Http\Controllers\CP\Collections; use Illuminate\Http\Request; +use Illuminate\Support\Arr; use Statamic\Contracts\Entries\Collection as CollectionContract; use Statamic\Facades\File; use Statamic\Http\Controllers\CP\CpController; class ScaffoldCollectionController extends CpController { + protected array $templateExtensions = [ + 'antlers' => '.antlers.html', + 'blade' => '.blade.php', + ]; + public function index($collection) { $this->authorize('store', CollectionContract::class, __('You are not authorized to scaffold resources.')); @@ -37,9 +43,20 @@ public function create(Request $request, $collection) ]; } + private function getTemplateFile($filename) + { + $extension = Arr::get( + $this->templateExtensions, + config('statamic.templates.engine', 'antlers'), + '.antlers.html' + ); + + return resource_path("views/{$filename}{$extension}"); + } + private function makeTemplate($filename) { - $file = resource_path("views/{$filename}.antlers.html"); + $file = $this->getTemplateFile($filename); // Don't overwrite existing if (! File::get($file)) {