title = 'Default Board'; $board->account = new NullAccount(1); $board->setStatus(DashboardBoardStatus::ACTIVE); DashboardBoardMapper::create()->execute($board); } /** * Install data from providing modules. * * The data can be either directories which should be created or files which should be "uploaded" * * @param ApplicationAbstract $app Application * @param array $data Additional data * * @return array * * @throws PathException * @throws \Exception * * @since 1.0.0 */ public static function installExternal(ApplicationAbstract $app, array $data) : array { if (!\is_file($data['path'] ?? '')) { throw new PathException($data['path'] ?? ''); } $dashboardFile = \file_get_contents($data['path'] ?? ''); if ($dashboardFile === false) { throw new PathException($data['path'] ?? ''); // @codeCoverageIgnore } $dashboardData = \json_decode($dashboardFile, true) ?? []; if ($dashboardData === false) { throw new \Exception(); // @codeCoverageIgnore } $result = [ 'component' => [], ]; $apiApp = new class() extends ApplicationAbstract { protected string $appName = 'Api'; }; $apiApp->dbPool = $app->dbPool; $apiApp->orgId = $app->orgId; $apiApp->accountManager = $app->accountManager; $apiApp->appSettings = $app->appSettings; $apiApp->moduleManager = $app->moduleManager; $apiApp->eventManager = $app->eventManager; foreach ($dashboardData as $dashboard) { switch ($dashboard['type']) { case 'component': $result['component'][] = self::createComponent($apiApp, $dashboard); break; default: } } return $result; } /** * Create board component. * * @param ApplicationAbstract $app Application * @param array $data Type info * * @return DashboardComponent * * @since 1.0.0 */ private static function createComponent(ApplicationAbstract $app, array $data) : DashboardComponent { $module = $app->moduleManager->get('Workflow'); $response = new HttpResponse(); $request = new HttpRequest(new HttpUri('')); $request->header->account = 1; $request->setData('board', (int) ($data['board'] ?? 0)); $request->setData('order', (int) ($data['order'] ?? 0)); $request->setData('module', (string) ($data['module'] ?? '')); $module->apiComponentCreate($request, $response); return $response->get('')['response']; } }