File tree Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ protected function isRoot(): bool
181
181
/**
182
182
* Replaces all raw placeholders within the provided string.
183
183
*/
184
- protected function resolveBlocks (string $ value ): string
184
+ public function resolveBlocks (string $ value ): string
185
185
{
186
186
$ placeholders = array_keys ($ this ->componentBlocks );
187
187
@@ -742,7 +742,7 @@ protected function simplifyNodes(array $nodes): array
742
742
743
743
protected function storeComponentBlock (string $ value ): string
744
744
{
745
- $ placeholder = '__RAW :: ' .Utils::makeRandomString ();
745
+ $ placeholder = '__DAGGER_RAW :: ' .Utils::makeRandomString ();
746
746
$ this ->componentBlocks [$ placeholder ] = $ value ;
747
747
748
748
return $ placeholder ;
Original file line number Diff line number Diff line change 16
16
* @method static bool compiledDynamicComponentExists(string $proxyName, string $componentName)
17
17
* @method static void compileDynamicComponent(array $proxyDetails, string $componentName)
18
18
* @method static CompilerOptions getOptions()
19
+ * @method static resolveBlocks(string $value): string
19
20
* @method static cleanup()
20
21
*/
21
22
class Compiler extends Facade
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ public function __construct(ViewManifest $manifest)
17
17
public function handle ()
18
18
{
19
19
Compiler::cleanup ();
20
+ ViewCreatingListener::clearCheckedViews ();
20
21
21
22
foreach ($ this ->manifest ->getTracked () as $ rootView => $ tracked ) {
22
23
file_put_contents (
Original file line number Diff line number Diff line change 2
2
3
3
namespace Stillat \Dagger \Listeners ;
4
4
5
+ use Illuminate \Support \Str ;
6
+ use Stillat \Dagger \Facades \Compiler ;
5
7
use Stillat \Dagger \Runtime \ViewManifest ;
6
8
7
9
class ViewCreatingListener
8
10
{
9
11
protected ViewManifest $ manifest ;
10
12
13
+ protected static array $ checkedViews = [];
14
+
11
15
public function __construct (ViewManifest $ manifest )
12
16
{
13
17
$ this ->manifest = $ manifest ;
14
18
}
15
19
16
20
public function create ($ view ): void
17
21
{
22
+ $ this ->checkForBladeRenderCall ($ view );
23
+
18
24
$ this ->manifest ->push ($ view );
19
25
20
26
$ this ->checkForInvalidation ($ view );
21
27
}
22
28
29
+ protected function checkForBladeRenderCall ($ view ): void
30
+ {
31
+ $ name = $ view ->getName ();
32
+
33
+ if (! Str::startsWith ($ name , '__components:: ' )) {
34
+ return ;
35
+ }
36
+
37
+ if (isset (static ::$ checkedViews [$ name ])) {
38
+ return ;
39
+ }
40
+
41
+ static ::$ checkedViews [$ name ] = true ;
42
+
43
+ $ path = $ view ->getPath ();
44
+
45
+ if (! file_exists ($ path )) {
46
+ return ;
47
+ }
48
+
49
+ file_put_contents (
50
+ $ path ,
51
+ Compiler::resolveBlocks (file_get_contents ($ path ))
52
+ );
53
+ }
54
+
55
+ public static function clearCheckedViews (): void
56
+ {
57
+ static ::$ checkedViews = [];
58
+ }
59
+
23
60
protected function checkForInvalidation ($ view ): void
24
61
{
25
62
$ name = $ view ->getName ();
You can’t perform that action at this time.
0 commit comments