1 | <?php |
||
2 | /** |
||
3 | * Created by PhpStorm. |
||
4 | * User: jgulledge |
||
5 | * Date: 10/6/2017 |
||
6 | * Time: 9:01 AM |
||
7 | */ |
||
8 | |||
9 | namespace LCI\Blend\Blendable; |
||
10 | |||
11 | |||
12 | class MediaSource extends Blendable |
||
13 | { |
||
14 | use BlendableProperties; |
||
15 | use DescriptionGetterAndSetter; |
||
16 | // return $this->blender->getElementSeedKeyFromName($this->getFieldName(), $this->xpdo_simple_object_class) |
||
17 | |||
18 | /** @var string */ |
||
19 | protected $opt_cache_key = 'media-sources'; |
||
20 | |||
21 | /** @var string ex: modResource */ |
||
22 | protected $xpdo_simple_object_class = 'modMediaSource'; |
||
23 | |||
24 | /** @var string */ |
||
25 | protected $unique_key_column = 'name'; |
||
26 | |||
27 | /** @var array ~ this should match data to be inserted via xPDO, ex [column_name => value, ...] */ |
||
28 | protected $blendable_xpdo_simple_object_data = [ |
||
29 | 'name' => '', |
||
30 | 'description' => '', |
||
31 | 'class_key' => 'sources.modFileMediaSource', |
||
32 | //`properties` mediumtext, |
||
33 | 'is_stream' => 1 |
||
34 | ]; |
||
35 | |||
36 | /** @var array ~ ['setMethodName' => 'setMethodActualName', 'setDoNotUseMethod' => false] overwrite in child classes */ |
||
37 | protected $load_from_array_aliases = [ |
||
38 | 'setProperties' => 'mergePropertiesFromArray' |
||
39 | ]; |
||
40 | |||
41 | protected $mediaSourceProcessor = null; |
||
42 | |||
43 | // create methods to match the column data: |
||
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | public function getFieldName() |
||
49 | { |
||
50 | return $this->blendable_xpdo_simple_object_data['name']; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @param string $name |
||
55 | * @return $this |
||
56 | */ |
||
57 | public function setFieldName($name) |
||
58 | { |
||
59 | $this->blendable_xpdo_simple_object_data['name'] = $name; |
||
60 | return $this; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return bool |
||
65 | */ |
||
66 | public function getFieldClassKey() |
||
67 | { |
||
68 | return $this->blendable_xpdo_simple_object_data['class_key']; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @param string $class_key |
||
73 | * @return $this |
||
74 | */ |
||
75 | public function setFieldClassKey($class_key) |
||
76 | { |
||
77 | $this->blendable_xpdo_simple_object_data['class_key'] = $class_key; |
||
78 | return $this; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function getFieldIsStream() |
||
85 | { |
||
86 | return $this->blendable_xpdo_simple_object_data['is_stream']; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @param bool $bool |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function setFieldIsStream($bool) |
||
94 | { |
||
95 | $this->blendable_xpdo_simple_object_data['is_stream'] = (int)$bool; |
||
96 | return $this; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * property helpers: |
||
101 | * @SEE: core/model/modx/sources/modfilemediasource.class.php -> getDefaultProperties |
||
102 | * @SEE: core/model/modx/sources/mods3mediasource.class.php -> getDefaultProperties |
||
103 | */ |
||
104 | |||
105 | |||
106 | /** |
||
107 | * @param string $value |
||
108 | * @return $this |
||
109 | */ |
||
110 | public function setPropertyBasePath($value) |
||
111 | { |
||
112 | $this->properties->setProperty('basePath', $value); |
||
0 ignored issues
–
show
|
|||
113 | return $this; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @param string $value |
||
118 | * @return $this |
||
119 | */ |
||
120 | public function setPropertyBasePathRelative($value) |
||
121 | { |
||
122 | $this->properties->setProperty('basePathRelative', $value); |
||
123 | return $this; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @param string $value |
||
128 | * @return $this |
||
129 | */ |
||
130 | public function setPropertyBaseUrl($value) |
||
131 | { |
||
132 | $this->properties->setProperty('baseUrl', $value); |
||
133 | return $this; |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @param string $value |
||
138 | * @return $this |
||
139 | */ |
||
140 | public function setPropertyBaseUrlRelative($value) |
||
141 | { |
||
142 | $this->properties->setProperty('baseUrlRelative', $value); |
||
143 | return $this; |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @param string $value ~ comma separated list, ex: jpg,jpeg,png,gif,svg |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function setPropertyAllowedFileTypes($value) |
||
151 | { |
||
152 | $this->properties->setProperty('allowedFileTypes', $value); |
||
153 | return $this; |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * @param string $value ~ comma separated list, ex: jpg,jpeg,png,gif,svg |
||
158 | * @return $this |
||
159 | */ |
||
160 | public function setPropertyImageExtensions($value) |
||
161 | { |
||
162 | $this->properties->setProperty('imageExtensions', $value); |
||
163 | return $this; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * @param string $value ~ one of: jpg,png,gif |
||
168 | * @return $this |
||
169 | */ |
||
170 | public function setPropertyThumbnailType($value) |
||
171 | { |
||
172 | $this->properties->setProperty('thumbnailType', $value); |
||
173 | return $this; |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * @param string $value ~ 1 to 100, default=90 |
||
178 | * @return $this |
||
179 | */ |
||
180 | public function setPropertyThumbnailQuality($value) |
||
181 | { |
||
182 | $this->properties->setProperty('thumbnailQuality', $value); |
||
183 | return $this; |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @param string $value ~ public or private |
||
188 | * @return $this |
||
189 | */ |
||
190 | public function setPropertyVisibility($value) |
||
191 | { |
||
192 | $this->properties->setProperty('visibility', $value); |
||
193 | return $this; |
||
194 | } |
||
195 | /** |
||
196 | * @param string $value ~ comma separated list: .svn,.git,_notes,nbproject,.idea,.DS_Store |
||
197 | * @return $this |
||
198 | */ |
||
199 | public function setPropertySkipFiles($value) |
||
200 | { |
||
201 | $this->properties->setProperty('skipFiles', $value); |
||
202 | return $this; |
||
203 | } |
||
204 | |||
205 | /** |
||
206 | * @param string $value ~ AWS S3: The URL of the Amazon S3 instance. |
||
207 | * @return $this |
||
208 | */ |
||
209 | public function setPropertyUrl($value) |
||
210 | { |
||
211 | $this->properties->setProperty('url', $value); |
||
212 | return $this; |
||
213 | } |
||
214 | /** |
||
215 | * @param string $value ~ AWS S3: Region of the bucket. Example: us-west-1 |
||
216 | * @return $this |
||
217 | */ |
||
218 | public function setPropertyRegion($value) |
||
219 | { |
||
220 | $this->properties->setProperty('region', $value); |
||
221 | return $this; |
||
222 | } |
||
223 | /** |
||
224 | * @param string $value ~ AWS S3: The S3 Bucket to load your data from. |
||
225 | * @return $this |
||
226 | */ |
||
227 | public function setPropertyBucket($value) |
||
228 | { |
||
229 | $this->properties->setProperty('bucket', $value); |
||
230 | return $this; |
||
231 | } |
||
232 | /** |
||
233 | * @param string $value ~ AWS S3: Optional path/folder prefix |
||
234 | * @return $this |
||
235 | */ |
||
236 | public function setPropertyPrefix($value) |
||
237 | { |
||
238 | $this->properties->setProperty('prefix', $value); |
||
239 | return $this; |
||
240 | } |
||
241 | /** |
||
242 | * @param string $value ~ AWS S3: The Amazon key for authentication to the bucket. |
||
243 | * @return $this |
||
244 | */ |
||
245 | public function setPropertyKey($value) |
||
246 | { |
||
247 | $this->properties->setProperty('Key', $value); |
||
248 | return $this; |
||
249 | } |
||
250 | /** |
||
251 | * @param string $value ~ AWS S3: The Amazon secret key for authentication to the bucket. |
||
252 | * @return $this |
||
253 | */ |
||
254 | public function setPropertySecretKey($value) |
||
255 | { |
||
256 | $this->properties->setProperty('secret_key', $value); |
||
257 | return $this; |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * Properly format the data here: |
||
262 | * @return array |
||
263 | */ |
||
264 | public function getPropertiesData() |
||
265 | { |
||
266 | $data = $this->properties->getData(); |
||
267 | |||
268 | $class = $this->modx->loadClass($this->blendable_xpdo_simple_object_data['class_key']); |
||
269 | $mediaObject = new $class($this->modx); |
||
270 | |||
271 | if (is_object($mediaObject) && method_exists($mediaObject, 'getDefaultProperties')) { |
||
272 | $default_props = $mediaObject->getDefaultProperties(); |
||
273 | |||
274 | foreach ($default_props as $key => $value) { |
||
275 | $set_value = $value; |
||
276 | if (isset($data[$key])) { |
||
277 | $set_value = $data[$key]; |
||
278 | } |
||
279 | $data[$key] = $set_value; |
||
280 | |||
281 | if (isset($data[$key]) && is_array($value) && is_string($set_value)) { |
||
282 | $data[$key] = $value; |
||
283 | $data[$key]['value'] = $set_value; |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | |||
288 | return $data; |
||
289 | } |
||
290 | |||
291 | /** |
||
292 | * @return Blendable |
||
293 | */ |
||
294 | public function getCurrentVersion() |
||
295 | { |
||
296 | /** @var MediaSource $mediaSource */ |
||
297 | $mediaSource = new self($this->modx, $this->blender, $this->getFieldName()); |
||
298 | return $mediaSource->setSeedsDir($this->getSeedsDir()); |
||
299 | } |
||
300 | } |
||
301 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.