1 | <?php |
||
5 | class Editable implements \JsonSerializable |
||
6 | { |
||
7 | /** |
||
8 | * Editable attributes. |
||
9 | * |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $attributes = []; |
||
13 | |||
14 | /** |
||
15 | * Editable constructor. |
||
16 | * |
||
17 | * @param string $name |
||
18 | */ |
||
19 | public function __construct(string $name) |
||
23 | |||
24 | /** |
||
25 | * Returns Editable's attributes. |
||
26 | * |
||
27 | * @return array |
||
28 | */ |
||
29 | public function attributes() |
||
33 | |||
34 | /** |
||
35 | * Data for JSON serialization. |
||
36 | * |
||
37 | * @return array |
||
38 | */ |
||
39 | public function jsonSerialize() |
||
43 | |||
44 | /** |
||
45 | * Sets editable title. |
||
46 | * |
||
47 | * @param string|null $title |
||
48 | * |
||
49 | * @return $this |
||
50 | */ |
||
51 | public function titledAs(string $title = null) |
||
57 | |||
58 | /** |
||
59 | * Sets editable type. |
||
60 | * |
||
61 | * @param string $type |
||
62 | * |
||
63 | * @return $this |
||
64 | */ |
||
65 | public function usingType(string $type) |
||
75 | |||
76 | /** |
||
77 | * Sets editable value. |
||
78 | * |
||
79 | * @param null $value |
||
80 | * |
||
81 | * @return $this |
||
82 | */ |
||
83 | public function withValue($value = null) |
||
89 | |||
90 | /** |
||
91 | * Sets editable options list. |
||
92 | * |
||
93 | * @param array $options |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function withOptions(array $options = []) |
||
109 | |||
110 | /** |
||
111 | * Sets custom editable attributes. |
||
112 | * |
||
113 | * @param array $attributes |
||
114 | * |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function withAttributes(array $attributes = []) |
||
123 | |||
124 | /** |
||
125 | * Set upload URL. |
||
126 | * |
||
127 | * @param string $url |
||
128 | * |
||
129 | * @return Editable |
||
130 | */ |
||
131 | public function uploadTo(string $url) |
||
135 | |||
136 | /** |
||
137 | * Set request headers. |
||
138 | * |
||
139 | * @param array $headers |
||
140 | * |
||
141 | * @return Editable |
||
142 | */ |
||
143 | public function withHeaders(array $headers) |
||
147 | |||
148 | /** |
||
149 | * Set custom setting value. |
||
150 | * |
||
151 | * @param string $setting |
||
152 | * @param $value |
||
153 | * |
||
154 | * @return $this |
||
155 | */ |
||
156 | public function withSetting(string $setting, $value) |
||
166 | |||
167 | /** |
||
168 | * Creates new placeholder and pushes it to editable's placeholders list. |
||
169 | * |
||
170 | * @param string $name |
||
171 | * @param string $title |
||
172 | * @param $value |
||
173 | * @param array $attributes |
||
174 | * |
||
175 | * @return $this |
||
176 | */ |
||
177 | public function placeholder(string $name, string $title, $value, array $attributes = []) |
||
190 | |||
191 | /** |
||
192 | * Creates multiple placeholders from array. |
||
193 | * |
||
194 | * @param array $placeholders |
||
195 | * @return $this |
||
196 | */ |
||
197 | public function placeholders(array $placeholders) |
||
209 | |||
210 | /** |
||
211 | * Sets inline mode. |
||
212 | * |
||
213 | * @param bool $inline = true |
||
214 | * |
||
215 | * @return $this |
||
216 | */ |
||
217 | public function asInline(bool $inline = true) |
||
223 | } |
||
224 |