()
| 23 | private static ?bool $overrideAllowDisabled = null; |
| 24 | |
| 25 | private static function init(): void |
| 26 | { |
| 27 | if (self::$initialized) { |
| 28 | return; |
| 29 | } |
| 30 | self::$initialized = true; |
| 31 | |
| 32 | $sessionId = null; |
| 33 | $allowDisabled = false; |
| 34 | if (self::$overrideId !== null) { |
| 35 | $sessionId = self::$overrideId; |
| 36 | self::$overrideId = null; |
| 37 | $allowDisabled = self::$overrideAllowDisabled === true; |
| 38 | self::$overrideAllowDisabled = null; |
| 39 | } elseif (!empty($_SESSION['active_source'])) { |
| 40 | $sessionId = (string)$_SESSION['active_source']; |
| 41 | } |
| 42 | |
| 43 | $cfg = SourcesConfig::getConfig(); |
| 44 | $enabled = !empty($cfg['enabled']); |
| 45 | if ($enabled) { |
| 46 | $source = SourcesConfig::getSource($sessionId); |
| 47 | if (!$source || (empty($source['enabled']) && !$allowDisabled)) { |
| 48 | $source = SourcesConfig::getFirstEnabledSource(); |
| 49 | } |
| 50 | if (!$source) { |
| 51 | $source = SourcesConfig::getDefaultSource(); |
| 52 | } |
| 53 | self::$activeSource = $source; |
| 54 | self::$activeId = (string)($source['id'] ?? self::DEFAULT_ID); |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | self::$activeId = self::DEFAULT_ID; |
| 59 | self::$activeSource = [ |
| 60 | 'id' => self::DEFAULT_ID, |
| 61 | 'name' => 'Local', |
| 62 | 'type' => 'local', |
| 63 | 'enabled' => true, |
| 64 | 'readOnly' => false, |
| 65 | 'disableTrash' => false, |
| 66 | 'config' => [ |
| 67 | 'path' => (string)UPLOAD_DIR, |
| 68 | ], |
| 69 | 'default' => true, |
| 70 | ]; |
| 71 | } |
| 72 | |
| 73 | public static function sourcesEnabled(): bool |
| 74 | { |
no test coverage detected