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' => [], ]; foreach ($dashboardData as $dashboard) { switch ($dashboard['type']) { case 'component': $result['component'][] = self::createComponent($app->dbPool, $dashboard); break; default: } } return $result; } /** * Create board component. * * @param DatabasePool $dbPool Database instance * @param array $data Type info * * @return EditorDocType * * @since 1.0.0 */ private static function createComponent(DatabasePool $dbPool, array $data) : DashboardComponent { $component = new DashboardComponent(); $component->board = (int) ($data['board'] ?? 0); $component->order = (int) ($data['order'] ?? 0); $component->module = (string) ($data['module'] ?? ''); DashboardComponentMapper::create()->execute($component); return $component; } }