Skip to content

Commit b749a89

Browse files
elzodyjuliusknorr
authored andcommitted
fix: PHP formatting
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
1 parent bb34b08 commit b749a89

7 files changed

Lines changed: 28 additions & 21 deletions

File tree

apps/files/lib/Controller/TemplateController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/**
2222
* @psalm-import-type FilesTemplateFile from ResponseDefinitions
2323
* @psalm-import-type FilesTemplateFileCreator from ResponseDefinitions
24+
* @psalm-import-type FilesTemplateField from ResponseDefinitions
2425
*/
2526
class TemplateController extends OCSController {
2627
protected $templateManager;
@@ -51,7 +52,7 @@ public function list(): DataResponse {
5152
* @param string $filePath Path of the file
5253
* @param string $templatePath Name of the template
5354
* @param string $templateType Type of the template
54-
* @param array $templateFields Fields of the template
55+
* @param FilesTemplateField[] $templateFields Fields of the template
5556
*
5657
* @return DataResponse<Http::STATUS_OK, FilesTemplateFile, array{}>
5758
* @throws OCSForbiddenException Creating template is not allowed

apps/files/lib/ResponseDefinitions.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
* ratio: ?float,
3333
* actionLabel: string,
3434
* }
35+
*
36+
* @psalm-type FilesTemplateField = array{
37+
* index: string,
38+
* content: string,
39+
* type: string,
40+
* }
3541
*/
3642
class ResponseDefinitions {
3743
}

apps/files/openapi.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,14 @@
10601060
"type": "string",
10611061
"default": "user",
10621062
"description": "Type of the template"
1063+
},
1064+
"templateFields": {
1065+
"type": "array",
1066+
"default": [],
1067+
"description": "Fields of the template",
1068+
"items": {
1069+
"$ref": "#/components/schemas/TemplateField"
1070+
}
10631071
}
10641072
}
10651073
}

apps/files/src/components/TemplateFiller.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</div>
2020

2121
<div class="template-field-modal__buttons">
22-
<NcLoadingIcon v-if="loading" :name="t('files', 'Submitting fields...')" />
22+
<NcLoadingIcon v-if="loading" :name="t('files', 'Submitting fields')" />
2323
<NcButton aria-label="Submit button"
2424
type="primary"
2525
@click="submit">

lib/public/Files/Template/BeforeGetTemplatesEvent.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -18,7 +20,7 @@ class BeforeGetTemplatesEvent extends Event {
1820

1921
/**
2022
* @param array<Template> $templates
21-
*
23+
*
2224
* @since 30.0.0
2325
*/
2426
public function __construct(array $templates) {
@@ -29,7 +31,7 @@ public function __construct(array $templates) {
2931

3032
/**
3133
* @return array<Template>
32-
*
34+
*
3335
* @since 30.0.0
3436
*/
3537
public function getTemplates(): array {

lib/public/Files/Template/Field.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
57
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -19,32 +21,18 @@ class Field implements \JsonSerializable {
1921
private ?string $tag;
2022

2123
/**
22-
* @param string $index
23-
* @param string $content
24-
* @param FieldType $type
25-
* @param ?string $alias
26-
* @param ?int $id
27-
* @param ?string $tag
28-
*
2924
* @since 30.0.0
3025
*/
31-
public function __construct($index, $content, $type, $alias = null, $id = null, $tag = null) {
26+
public function __construct(string $index, string $content, FieldType $type, ?string $alias = null, ?int $id = null, ?string $tag = null) {
3227
$this->index = $index;
3328
$this->alias = $alias;
29+
$this->type = $type;
3430
$this->id = $id;
3531
$this->tag = $tag;
3632
$this->content = $content;
37-
38-
if ($type instanceof FieldType) {
39-
$this->type = $type;
40-
} else {
41-
$this->type = FieldType::tryFrom($type) ?? throw new InvalidFieldTypeException();
42-
}
4333
}
4434

4535
/**
46-
* @return array
47-
*
4836
* @since 30.0.0
4937
*/
5038
public function jsonSerialize(): array {

lib/public/Files/Template/ITemplateManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ public function initializeTemplateDirectory(?string $path = null, ?string $userI
6767
/**
6868
* @param string $filePath
6969
* @param string $templateId
70+
* @param string $templateType
71+
* @param array $templateFields Since 30.0.0
7072
* @return array
7173
* @throws GenericFileException
7274
* @since 21.0.0
7375
*/
74-
public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user'): array;
76+
public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user', array $templateFields = []): array;
7577
}

0 commit comments

Comments
 (0)