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
class AnonymousComponent extends Component
6
{
7
    /**
8
     * The component view.
9
     *
10
     * @var string
11
     */
12
    protected $view;
13
 
14
    /**
15
     * The component data.
16
     *
17
     * @var array
18
     */
19
    protected $data = [];
20
 
21
    /**
22
     * Create a new anonymous component instance.
23
     *
24
     * @param  string  $view
25
     * @param  array  $data
26
     * @return void
27
     */
28
    public function __construct($view, $data)
29
    {
30
        $this->view = $view;
31
        $this->data = $data;
32
    }
33
 
34
    /**
35
     * Get the view / view contents that represent the component.
36
     *
37
     * @return string
38
     */
39
    public function render()
40
    {
41
        return $this->view;
42
    }
43
 
44
    /**
45
     * Get the data that should be supplied to the view.
46
     *
47
     * @return array
48
     */
49
    public function data()
50
    {
51
        $this->attributes = $this->attributes ?: $this->newAttributeBag();
52
 
53
        return array_merge(
54
            ($this->data['attributes'] ?? null)?->getAttributes() ?: [],
55
            $this->attributes->getAttributes(),
56
            $this->data,
57
            ['attributes' => $this->attributes]
58
        );
59
    }
60
}