MCPcopy Create free account
hub / github.com/error311/FileRise / buildSourceView

Method buildSourceView

src/FileRise/Storage/SourcesConfig.php:223–263  ·  view source on GitHub ↗
(array $src, bool $includeSecrets, bool $adminView)

Source from the content-addressed store, hash-verified

221 }
222
223 private static function buildSourceView(array $src, bool $includeSecrets, bool $adminView): array
224 {
225 $out = [
226 'id' => $src['id'],
227 'name' => $src['name'],
228 'type' => $src['type'],
229 'enabled' => !empty($src['enabled']),
230 'readOnly' => !empty($src['readOnly']),
231 'disableTrash' => !empty($src['disableTrash']),
232 ];
233
234 $cfg = isset($src['config']) && is_array($src['config']) ? $src['config'] : [];
235 if ($src['type'] === 'local') {
236 $out['config'] = [
237 'path' => (string)($cfg['path'] ?? ''),
238 ];
239 return $out;
240 }
241
242 if ($src['type'] === 'webdav') {
243 $config = [
244 'baseUrl' => (string)($cfg['baseUrl'] ?? $cfg['url'] ?? ''),
245 'username' => (string)($cfg['username'] ?? ''),
246 'root' => (string)($cfg['root'] ?? $cfg['path'] ?? ''),
247 'verifyTls' => !isset($cfg['verifyTls']) || $cfg['verifyTls'] !== false,
248 ];
249 $hasPassword = !empty($cfg['passwordEnc']);
250
251 if ($includeSecrets) {
252 $config['password'] = $hasPassword ? self::decryptSecret((string)$cfg['passwordEnc']) : '';
253 } elseif ($adminView) {
254 $config['hasPassword'] = $hasPassword;
255 }
256
257 $out['config'] = $config;
258 return $out;
259 }
260
261 $out['config'] = [];
262 return $out;
263 }
264
265 public static function sourcesEnabled(): bool
266 {

Callers 7

getConfigMethod · 0.95
getPublicConfigMethod · 0.95
getAdminListMethod · 0.95
getSourceMethod · 0.95
getFirstEnabledSourceMethod · 0.95
getDefaultSourceMethod · 0.95
upsertSourceMethod · 0.95

Calls 1

decryptSecretMethod · 0.95

Tested by

no test coverage detected