@@ -69,57 +69,57 @@ discard block |
||
| 69 | 69 | #[ApiRoute(verb: 'GET', url: '/tasktypes', root: '/taskprocessing')] |
| 70 | 70 | public function taskTypes(): DataResponse { |
| 71 | 71 | /** @var array<string, CoreTaskProcessingTaskType> $taskTypes */ |
| 72 | - $taskTypes = array_map(function (array $tt) { |
|
| 73 | - $tt['inputShape'] = array_map(function ($descriptor) { |
|
| 72 | + $taskTypes = array_map(function(array $tt) { |
|
| 73 | + $tt['inputShape'] = array_map(function($descriptor) { |
|
| 74 | 74 | return $descriptor->jsonSerialize(); |
| 75 | 75 | }, $tt['inputShape']); |
| 76 | 76 | if (empty($tt['inputShape'])) { |
| 77 | 77 | $tt['inputShape'] = new stdClass; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $tt['outputShape'] = array_map(function ($descriptor) { |
|
| 80 | + $tt['outputShape'] = array_map(function($descriptor) { |
|
| 81 | 81 | return $descriptor->jsonSerialize(); |
| 82 | 82 | }, $tt['outputShape']); |
| 83 | 83 | if (empty($tt['outputShape'])) { |
| 84 | 84 | $tt['outputShape'] = new stdClass; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $tt['optionalInputShape'] = array_map(function ($descriptor) { |
|
| 87 | + $tt['optionalInputShape'] = array_map(function($descriptor) { |
|
| 88 | 88 | return $descriptor->jsonSerialize(); |
| 89 | 89 | }, $tt['optionalInputShape']); |
| 90 | 90 | if (empty($tt['optionalInputShape'])) { |
| 91 | 91 | $tt['optionalInputShape'] = new stdClass; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $tt['optionalOutputShape'] = array_map(function ($descriptor) { |
|
| 94 | + $tt['optionalOutputShape'] = array_map(function($descriptor) { |
|
| 95 | 95 | return $descriptor->jsonSerialize(); |
| 96 | 96 | }, $tt['optionalOutputShape']); |
| 97 | 97 | if (empty($tt['optionalOutputShape'])) { |
| 98 | 98 | $tt['optionalOutputShape'] = new stdClass; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $tt['inputShapeEnumValues'] = array_map(function (array $enumValues) { |
|
| 101 | + $tt['inputShapeEnumValues'] = array_map(function(array $enumValues) { |
|
| 102 | 102 | return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 103 | 103 | }, $tt['inputShapeEnumValues']); |
| 104 | 104 | if (empty($tt['inputShapeEnumValues'])) { |
| 105 | 105 | $tt['inputShapeEnumValues'] = new stdClass; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $tt['optionalInputShapeEnumValues'] = array_map(function (array $enumValues) { |
|
| 108 | + $tt['optionalInputShapeEnumValues'] = array_map(function(array $enumValues) { |
|
| 109 | 109 | return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 110 | 110 | }, $tt['optionalInputShapeEnumValues']); |
| 111 | 111 | if (empty($tt['optionalInputShapeEnumValues'])) { |
| 112 | 112 | $tt['optionalInputShapeEnumValues'] = new stdClass; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $tt['outputShapeEnumValues'] = array_map(function (array $enumValues) { |
|
| 115 | + $tt['outputShapeEnumValues'] = array_map(function(array $enumValues) { |
|
| 116 | 116 | return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 117 | 117 | }, $tt['outputShapeEnumValues']); |
| 118 | 118 | if (empty($tt['outputShapeEnumValues'])) { |
| 119 | 119 | $tt['outputShapeEnumValues'] = new stdClass; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $tt['optionalOutputShapeEnumValues'] = array_map(function (array $enumValues) { |
|
| 122 | + $tt['optionalOutputShapeEnumValues'] = array_map(function(array $enumValues) { |
|
| 123 | 123 | return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues); |
| 124 | 124 | }, $tt['optionalOutputShapeEnumValues']); |
| 125 | 125 | if (empty($tt['optionalOutputShapeEnumValues'])) { |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | public function listTasksByApp(string $appId, ?string $customId = null): DataResponse { |
| 257 | 257 | try { |
| 258 | 258 | $tasks = $this->taskProcessingManager->getUserTasksByApp($this->userId, $appId, $customId); |
| 259 | - $json = array_map(static function (Task $task) { |
|
| 259 | + $json = array_map(static function(Task $task) { |
|
| 260 | 260 | return $task->jsonSerialize(); |
| 261 | 261 | }, $tasks); |
| 262 | 262 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | public function listTasks(?string $taskType, ?string $customId = null): DataResponse { |
| 283 | 283 | try { |
| 284 | 284 | $tasks = $this->taskProcessingManager->getUserTasks($this->userId, $taskType, $customId); |
| 285 | - $json = array_map(static function (Task $task) { |
|
| 285 | + $json = array_map(static function(Task $task) { |
|
| 286 | 286 | return $task->jsonSerialize(); |
| 287 | 287 | }, $tasks); |
| 288 | 288 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | #[NoAdminRequired] |
| 308 | 308 | #[NoCSRFRequired] |
| 309 | 309 | #[ApiRoute(verb: 'GET', url: '/tasks/{taskId}/file/{fileId}', root: '/taskprocessing')] |
| 310 | - public function getFileContents(int $taskId, int $fileId): StreamResponse|DataResponse { |
|
| 310 | + public function getFileContents(int $taskId, int $fileId): StreamResponse | DataResponse { |
|
| 311 | 311 | try { |
| 312 | 312 | $task = $this->taskProcessingManager->getUserTask($taskId, $this->userId); |
| 313 | 313 | return $this->getFileContentsInternal($task, $fileId); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | #[ExAppRequired] |
| 334 | 334 | #[ApiRoute(verb: 'GET', url: '/tasks_provider/{taskId}/file/{fileId}', root: '/taskprocessing')] |
| 335 | - public function getFileContentsExApp(int $taskId, int $fileId): StreamResponse|DataResponse { |
|
| 335 | + public function getFileContentsExApp(int $taskId, int $fileId): StreamResponse | DataResponse { |
|
| 336 | 336 | try { |
| 337 | 337 | $task = $this->taskProcessingManager->getTask($taskId); |
| 338 | 338 | return $this->getFileContentsInternal($task, $fileId); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | * |
| 387 | 387 | * @return StreamResponse<Http::STATUS_OK, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}> |
| 388 | 388 | */ |
| 389 | - private function getFileContentsInternal(Task $task, int $fileId): StreamResponse|DataResponse { |
|
| 389 | + private function getFileContentsInternal(Task $task, int $fileId): StreamResponse | DataResponse { |
|
| 390 | 390 | $ids = $this->taskProcessingManager->extractFileIdsFromTask($task); |
| 391 | 391 | if (!in_array($fileId, $ids)) { |
| 392 | 392 | return new DataResponse(['message' => $this->l->t('Not found')], Http::STATUS_NOT_FOUND); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | } |
| 397 | 397 | $node = $this->rootFolder->getFirstNodeById($fileId); |
| 398 | 398 | if ($node === null) { |
| 399 | - $node = $this->rootFolder->getFirstNodeByIdInPath($fileId, '/' . $this->rootFolder->getAppDataDirectoryName() . '/'); |
|
| 399 | + $node = $this->rootFolder->getFirstNodeByIdInPath($fileId, '/'.$this->rootFolder->getAppDataDirectoryName().'/'); |
|
| 400 | 400 | if (!$node instanceof File) { |
| 401 | 401 | throw new NotFoundException('Node is not a file'); |
| 402 | 402 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $response = new StreamResponse($node->fopen('rb')); |
| 419 | 419 | $response->addHeader( |
| 420 | 420 | 'Content-Disposition', |
| 421 | - 'attachment; filename="' . rawurldecode($node->getName()) . '"' |
|
| 421 | + 'attachment; filename="'.rawurldecode($node->getName()).'"' |
|
| 422 | 422 | ); |
| 423 | 423 | $response->addHeader('Content-Type', $contentType); |
| 424 | 424 | return $response; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | // proceed to ignore this task |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - $taskIdsToIgnore[] = (int)$task->getId(); |
|
| 558 | + $taskIdsToIgnore[] = (int) $task->getId(); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | /** @var CoreTaskProcessingTask $json */ |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | $folder = $this->appData->newFolder('TaskProcessing'); |
| 642 | 642 | } |
| 643 | 643 | /** @var SimpleFile $file */ |
| 644 | - $file = $folder->newFile(time() . '-' . rand(1, 100000), $data); |
|
| 644 | + $file = $folder->newFile(time().'-'.rand(1, 100000), $data); |
|
| 645 | 645 | return $file->getId(); |
| 646 | 646 | } |
| 647 | 647 | |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | * @return array |
| 652 | 652 | */ |
| 653 | 653 | private function intersectTaskTypesAndProviders(array $taskTypeIds, array $providerIds): array { |
| 654 | - $providerIdsBasedOnTaskTypesWithNull = array_unique(array_map(function ($taskTypeId) { |
|
| 654 | + $providerIdsBasedOnTaskTypesWithNull = array_unique(array_map(function($taskTypeId) { |
|
| 655 | 655 | try { |
| 656 | 656 | return $this->taskProcessingManager->getPreferredProvider($taskTypeId)->getId(); |
| 657 | 657 | } catch (Exception) { |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | $possibleProviderIds = array_values(array_intersect($providerIdsBasedOnTaskTypes, $providerIds)); |
| 666 | 666 | |
| 667 | 667 | // restrict $taskTypeIds to task types that can actually be run by one of the now restricted providers |
| 668 | - $possibleTaskTypeIds = array_values(array_filter($taskTypeIds, function ($taskTypeId) use ($possibleProviderIds) { |
|
| 668 | + $possibleTaskTypeIds = array_values(array_filter($taskTypeIds, function($taskTypeId) use ($possibleProviderIds) { |
|
| 669 | 669 | try { |
| 670 | 670 | $providerForTaskType = $this->taskProcessingManager->getPreferredProvider($taskTypeId)->getId(); |
| 671 | 671 | } catch (Exception) { |