dbPool = $app->dbPool; $apiApp->orgId = $app->orgId; $apiApp->accountManager = $app->accountManager; $apiApp->appSettings = $app->appSettings; $apiApp->moduleManager = $app->moduleManager; $apiApp->eventManager = $app->eventManager; foreach ($workflowData as $workflow) { self::installWorkflow($apiApp, $workflow); } return []; } /** * Install application page. * * @param ApplicationAbstract $app Application * @param array $data Additional data * * @return void * * @since 1.0.0 */ private static function installWorkflow(ApplicationAbstract $app, array $data) : void { /** @var \Modules\Workflow\Controller\ApiController $module */ $module = $app->moduleManager->get('Workflow'); $response = new HttpResponse(); $request = new HttpRequest(new HttpUri('')); $request->header->account = 1; $request->setData('name', $data['name']); $tempPath = __DIR__ . '/../../../temp/'; $workflowFiles = \scandir(__DIR__ . '/../../..' . $data['path']); if ($workflowFiles === false) { return; } foreach ($workflowFiles as $filePath) { if (!\is_file(__DIR__ . '/../../..' . $data['path'] . '/' . $filePath) || $filePath === '..' || $filePath === '.') { continue; } \copy( __DIR__ . '/../../..' . $data['path'] . '/' . $filePath, $tempPath . $filePath ); $request->addFile([ 'error' => \UPLOAD_ERR_OK, 'type' => \substr($filePath, \strrpos($filePath, '.') + 1), 'name' => $filePath, 'tmp_name' => $tempPath . $filePath, 'size' => \filesize($tempPath . $filePath), ]); } $module->apiWorkflowTemplateCreate($request, $response); } }