/**
* @psalm-import-type FilesTemplateFile from ResponseDefinitions
* @psalm-import-type FilesTemplateFileCreator from ResponseDefinitions
+ * @psalm-import-type FilesTemplateField from ResponseDefinitions
*/
class TemplateController extends OCSController {
protected $templateManager;
* @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
* ratio: ?float,
* actionLabel: string,
* }
+ *
+ * @psalm-type FilesTemplateField = array{
+ * index: string,
+ * content: string,
+ * type: string,
+ * }
*/
class ResponseDefinitions {
}
"type": "string",
"default": "user",
"description": "Type of the template"
+ },
+ "templateFields": {
+ "type": "array",
+ "default": [],
+ "description": "Fields of the template",
+ "items": {
+ "$ref": "#/components/schemas/TemplateField"
+ }
}
}
}
</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">
<?php
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
/**
* @param array<Template> $templates
- *
+ *
* @since 30.0.0
*/
public function __construct(array $templates) {
/**
* @return array<Template>
- *
+ *
* @since 30.0.0
*/
public function getTemplates(): array {
<?php
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
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 {
/**
* @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;
}