-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
249 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Bnomei\Blueprints; | ||
|
||
use Kirby\Cms\FileBlueprint; | ||
use Kirby\Cms\PageBlueprint; | ||
use Kirby\Cms\UserBlueprint; | ||
|
||
trait HasBlueprintCache | ||
{ | ||
protected static bool $blueprintCache = false; | ||
|
||
public function blueprintCacheKey(): string | ||
{ | ||
$blueprint = $this->blueprint(); | ||
$type = match ($blueprint::class) { | ||
PageBlueprint::class => 'pages', | ||
FileBlueprint::class => 'files', | ||
UserBlueprint::class => 'users', | ||
}; | ||
|
||
return $type.'/'.$blueprint->name(); | ||
} | ||
|
||
public function __destruct() | ||
{ | ||
/** @var \Kirby\Cms\ModelWithContent $this */ | ||
$key = $this->blueprintCacheKey(); | ||
if (static::$blueprintCache) { | ||
return; | ||
} | ||
static::$blueprintCache = true; | ||
|
||
if (BlueprintCache::exists($key) === false) { | ||
$blueprint = $this->blueprint(); | ||
$data = $blueprint->toArray(); | ||
if (isset(static::$blueprintCacheResolve)) { | ||
foreach ($blueprint->toArray()['tabs'] as $tabKey => $tab) { | ||
foreach ($tab['columns'] as $columnKey => $column) { | ||
foreach ($column['sections'] as $sectionKey => $section) { | ||
$section = $blueprint->section($sectionKey); | ||
$data['tabs'][$tabKey]['columns'][$columnKey]['sections'][$sectionKey]['fields'] = $section->toArray()['fields']; | ||
} | ||
} | ||
} | ||
} | ||
BlueprintCache::set($key, $data); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Bnomei\Blueprints; | ||
|
||
trait HasBlueprintCacheResolve | ||
{ | ||
protected static bool $blueprintCacheResolve = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Uuid: 2TNU3cFebBEBQm6H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Text: | ||
|
||
---- | ||
|
||
Blocks: [{"content":{"location":"kirby","image":[],"src":"","alt":"","caption":"","link":"","ratio":"","crop":"false"},"id":"bf3ab53f-f5a2-499c-a684-6b74c779f2eb","isHidden":false,"type":"image"},{"content":{"text":""},"id":"f3fda5bc-d4f6-4351-9378-5ec0f36e933a","isHidden":false,"type":"text"},{"content":{"code":"","language":"text"},"id":"cfb1028f-c85e-4434-92c5-d779dfcc7e77","isHidden":false,"type":"code"}] | ||
|
||
---- | ||
|
||
Uuid: 2TNU3cFebBEBQm6H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type: text | ||
label: extme | ||
placeholder: extme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
class ExamplePage extends \Kirby\Cms\Page | ||
{ | ||
use \Bnomei\Blueprints\HasBlueprintCache; | ||
use \Bnomei\Blueprints\HasBlueprintCacheResolve; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: Someblo | ||
fields: | ||
title: | ||
label: Title | ||
type: text | ||
text: fields/extme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
title: example | ||
|
||
fields: | ||
text: | ||
extends: fields/extme | ||
placeholder: "{{ page.title }}" | ||
blocks: | ||
type: blocks | ||
fieldsets: | ||
- text | ||
- image | ||
- video | ||
- quote | ||
- code | ||
- gallery |
Oops, something went wrong.