()
| 35 | } |
| 36 | |
| 37 | public function installDemo(): array { |
| 38 | $key = 'analytics-demo-' . $this->userId; |
| 39 | $this->locking->acquireLock($key, ILockingProvider::LOCK_EXCLUSIVE); |
| 40 | try { |
| 41 | $id = (int)$this->config->getUserValue($this->userId, 'analytics', 'business-demo-panorama', '0'); |
| 42 | if ($id > 0 && $this->panoramas->isOwn($id)) return ['kind' => 'bundle', 'panoramaId' => $id, 'reused' => true]; |
| 43 | $raw = file_get_contents(__DIR__ . '/../../resources/demo.json'); |
| 44 | if ($raw === false) throw new \RuntimeException('Demo bundle unavailable'); |
| 45 | return $this->importBundle(json_decode($raw, true, 512, JSON_THROW_ON_ERROR), true); |
| 46 | } finally { |
| 47 | $this->locking->releaseLock($key, ILockingProvider::LOCK_EXCLUSIVE); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | public function importBundle(array $bundle, bool $demo = false): array { |
| 52 | BundleDefinition::validate($bundle); |
nothing calls this directly
no test coverage detected