Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\View\Compilers\Concerns;
4
 
5
use Illuminate\Support\Str;
6
 
7
trait CompilesStacks
8
{
9
    /**
10
     * Compile the stack statements into the content.
11
     *
12
     * @param  string  $expression
13
     * @return string
14
     */
15
    protected function compileStack($expression)
16
    {
17
        return "<?php echo \$__env->yieldPushContent{$expression}; ?>";
18
    }
19
 
20
    /**
21
     * Compile the push statements into valid PHP.
22
     *
23
     * @param  string  $expression
24
     * @return string
25
     */
26
    protected function compilePush($expression)
27
    {
28
        return "<?php \$__env->startPush{$expression}; ?>";
29
    }
30
 
31
    /**
32
     * Compile the push-once statements into valid PHP.
33
     *
34
     * @param  string  $expression
35
     * @return string
36
     */
37
    protected function compilePushOnce($expression)
38
    {
39
        $parts = explode(',', $this->stripParentheses($expression), 2);
40
 
41
        [$stack, $id] = [$parts[0], $parts[1] ?? ''];
42
 
43
        $id = trim($id) ?: "'".(string) Str::uuid()."'";
44
 
45
        return '<?php if (! $__env->hasRenderedOnce('.$id.')): $__env->markAsRenderedOnce('.$id.');
46
$__env->startPush('.$stack.'); ?>';
47
    }
48
 
49
    /**
50
     * Compile the end-push statements into valid PHP.
51
     *
52
     * @return string
53
     */
54
    protected function compileEndpush()
55
    {
56
        return '<?php $__env->stopPush(); ?>';
57
    }
58
 
59
    /**
60
     * Compile the end-push-once statements into valid PHP.
61
     *
62
     * @return string
63
     */
64
    protected function compileEndpushOnce()
65
    {
66
        return '<?php $__env->stopPush(); endif; ?>';
67
    }
68
 
69
    /**
70
     * Compile the prepend statements into valid PHP.
71
     *
72
     * @param  string  $expression
73
     * @return string
74
     */
75
    protected function compilePrepend($expression)
76
    {
77
        return "<?php \$__env->startPrepend{$expression}; ?>";
78
    }
79
 
80
    /**
81
     * Compile the prepend-once statements into valid PHP.
82
     *
83
     * @param  string  $expression
84
     * @return string
85
     */
86
    protected function compilePrependOnce($expression)
87
    {
88
        $parts = explode(',', $this->stripParentheses($expression), 2);
89
 
90
        [$stack, $id] = [$parts[0], $parts[1] ?? ''];
91
 
92
        $id = trim($id) ?: "'".(string) Str::uuid()."'";
93
 
94
        return '<?php if (! $__env->hasRenderedOnce('.$id.')): $__env->markAsRenderedOnce('.$id.');
95
$__env->startPrepend('.$stack.'); ?>';
96
    }
97
 
98
    /**
99
     * Compile the end-prepend statements into valid PHP.
100
     *
101
     * @return string
102
     */
103
    protected function compileEndprepend()
104
    {
105
        return '<?php $__env->stopPrepend(); ?>';
106
    }
107
 
108
    /**
109
     * Compile the end-prepend-once statements into valid PHP.
110
     *
111
     * @return string
112
     */
113
    protected function compileEndprependOnce()
114
    {
115
        return '<?php $__env->stopPrepend(); endif; ?>';
116
    }
117
}