Skip to content

Commit

Permalink
fix: PHP formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody authored and juliusknorr committed Jul 25, 2024
1 parent bb34b08 commit b749a89
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion apps/files/lib/Controller/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/**
* @psalm-import-type FilesTemplateFile from ResponseDefinitions
* @psalm-import-type FilesTemplateFileCreator from ResponseDefinitions
* @psalm-import-type FilesTemplateField from ResponseDefinitions
*/
class TemplateController extends OCSController {
protected $templateManager;
Expand Down Expand Up @@ -51,7 +52,7 @@ public function list(): DataResponse {
* @param string $filePath Path of the file
* @param string $templatePath Name of the template
* @param string $templateType Type of the template
* @param array $templateFields Fields of the template
* @param FilesTemplateField[] $templateFields Fields of the template
*
* @return DataResponse<Http::STATUS_OK, FilesTemplateFile, array{}>
* @throws OCSForbiddenException Creating template is not allowed
Expand Down
6 changes: 6 additions & 0 deletions apps/files/lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
* ratio: ?float,
* actionLabel: string,
* }
*
* @psalm-type FilesTemplateField = array{
* index: string,
* content: string,
* type: string,
* }
*/
class ResponseDefinitions {
}
8 changes: 8 additions & 0 deletions apps/files/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,14 @@
"type": "string",
"default": "user",
"description": "Type of the template"
},
"templateFields": {
"type": "array",
"default": [],
"description": "Fields of the template",
"items": {
"$ref": "#/components/schemas/TemplateField"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/TemplateFiller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>

<div class="template-field-modal__buttons">
<NcLoadingIcon v-if="loading" :name="t('files', 'Submitting fields...')" />
<NcLoadingIcon v-if="loading" :name="t('files', 'Submitting fields')" />
<NcButton aria-label="Submit button"
type="primary"
@click="submit">
Expand Down
6 changes: 4 additions & 2 deletions lib/public/Files/Template/BeforeGetTemplatesEvent.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -18,7 +20,7 @@ class BeforeGetTemplatesEvent extends Event {

/**
* @param array<Template> $templates
*
*
* @since 30.0.0
*/
public function __construct(array $templates) {
Expand All @@ -29,7 +31,7 @@ public function __construct(array $templates) {

/**
* @return array<Template>
*
*
* @since 30.0.0
*/
public function getTemplates(): array {
Expand Down
20 changes: 4 additions & 16 deletions lib/public/Files/Template/Field.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -19,32 +21,18 @@ class Field implements \JsonSerializable {
private ?string $tag;

/**
* @param string $index
* @param string $content
* @param FieldType $type
* @param ?string $alias
* @param ?int $id
* @param ?string $tag
*
* @since 30.0.0
*/
public function __construct($index, $content, $type, $alias = null, $id = null, $tag = null) {
public function __construct(string $index, string $content, FieldType $type, ?string $alias = null, ?int $id = null, ?string $tag = null) {
$this->index = $index;
$this->alias = $alias;
$this->type = $type;
$this->id = $id;
$this->tag = $tag;
$this->content = $content;

if ($type instanceof FieldType) {
$this->type = $type;
} else {
$this->type = FieldType::tryFrom($type) ?? throw new InvalidFieldTypeException();
}
}

/**
* @return array
*
* @since 30.0.0
*/
public function jsonSerialize(): array {
Expand Down
4 changes: 3 additions & 1 deletion lib/public/Files/Template/ITemplateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ public function initializeTemplateDirectory(?string $path = null, ?string $userI
/**
* @param string $filePath
* @param string $templateId
* @param string $templateType
* @param array $templateFields Since 30.0.0
* @return array
* @throws GenericFileException
* @since 21.0.0
*/
public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user'): array;
public function createFromTemplate(string $filePath, string $templateId = '', string $templateType = 'user', array $templateFields = []): array;
}

0 comments on commit b749a89

Please sign in to comment.