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;
4
 
5
use Illuminate\Contracts\Support\Htmlable;
6
 
7
class ComponentSlot implements Htmlable
8
{
9
    /**
10
     * The slot attribute bag.
11
     *
12
     * @var \Illuminate\View\ComponentAttributeBag
13
     */
14
    public $attributes;
15
 
16
    /**
17
     * The slot contents.
18
     *
19
     * @var string
20
     */
21
    protected $contents;
22
 
23
    /**
24
     * Create a new slot instance.
25
     *
26
     * @param  string  $contents
27
     * @param  array  $attributes
28
     * @return void
29
     */
30
    public function __construct($contents = '', $attributes = [])
31
    {
32
        $this->contents = $contents;
33
 
34
        $this->withAttributes($attributes);
35
    }
36
 
37
    /**
38
     * Set the extra attributes that the slot should make available.
39
     *
40
     * @param  array  $attributes
41
     * @return $this
42
     */
43
    public function withAttributes(array $attributes)
44
    {
45
        $this->attributes = new ComponentAttributeBag($attributes);
46
 
47
        return $this;
48
    }
49
 
50
    /**
51
     * Get the slot's HTML string.
52
     *
53
     * @return string
54
     */
55
    public function toHtml()
56
    {
57
        return $this->contents;
58
    }
59
 
60
    /**
61
     * Determine if the slot is empty.
62
     *
63
     * @return bool
64
     */
65
    public function isEmpty()
66
    {
67
        return $this->contents === '';
68
    }
69
 
70
    /**
71
     * Determine if the slot is not empty.
72
     *
73
     * @return bool
74
     */
75
    public function isNotEmpty()
76
    {
77
        return ! $this->isEmpty();
78
    }
79
 
80
    /**
81
     * Get the slot's HTML string.
82
     *
83
     * @return string
84
     */
85
    public function __toString()
86
    {
87
        return $this->toHtml();
88
    }
89
}