1 | <?php namespace Arcanedev\LaravelHtml\Traits; |
||
12 | trait Componentable |
||
13 | { |
||
14 | /* ------------------------------------------------------------------------------------------------ |
||
15 | | Properties |
||
16 | | ------------------------------------------------------------------------------------------------ |
||
17 | */ |
||
18 | /** |
||
19 | * The registered components. |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected static $components = []; |
||
24 | |||
25 | /* ------------------------------------------------------------------------------------------------ |
||
26 | | Main Functions |
||
27 | | ------------------------------------------------------------------------------------------------ |
||
28 | */ |
||
29 | /** |
||
30 | * Register a custom component. |
||
31 | * |
||
32 | * @param string $name |
||
33 | * @param string $view |
||
34 | * @param array $signature |
||
35 | */ |
||
36 | 8 | public static function component($name, $view, array $signature) |
|
40 | |||
41 | /** |
||
42 | * Check if a component is registered. |
||
43 | * |
||
44 | * @param string $name |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | 8 | public static function hasComponent($name) |
|
52 | |||
53 | /* ------------------------------------------------------------------------------------------------ |
||
54 | | Other Functions |
||
55 | | ------------------------------------------------------------------------------------------------ |
||
56 | */ |
||
57 | /** |
||
58 | * Render a custom component. |
||
59 | * |
||
60 | * @param string $name |
||
61 | * @param array $arguments |
||
62 | * |
||
63 | * @return \Illuminate\Contracts\View\View |
||
64 | */ |
||
65 | protected function renderComponent($name, array $arguments) |
||
74 | |||
75 | /** |
||
76 | * Prepare the component data, while respecting provided defaults. |
||
77 | * |
||
78 | * @param array $signature |
||
79 | * @param array $arguments |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | protected function getComponentData(array $signature, array $arguments) |
||
100 | |||
101 | /** |
||
102 | * Dynamically handle calls to the class. |
||
103 | * |
||
104 | * @param string $method |
||
105 | * @param array $parameters |
||
106 | * |
||
107 | * @return \Illuminate\Contracts\View\View|mixed |
||
108 | * |
||
109 | * @throws \BadMethodCallException |
||
110 | */ |
||
111 | public function __call($method, $parameters) |
||
119 | } |
||
120 |