Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnathonKoster committed Oct 27, 2024
1 parent 1a3e110 commit 933c3a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config/templates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'engine' => 'antlers',
];
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 933c3a9

Please sign in to comment.