]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: PHP formatting
authorElizabeth Danzberger <lizzy7128@tutanota.de>
Wed, 24 Jul 2024 23:47:14 +0000 (19:47 -0400)
committerJulius Härtl <jus@bitgrid.net>
Thu, 25 Jul 2024 09:11:41 +0000 (11:11 +0200)
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
apps/files/lib/Controller/TemplateController.php
apps/files/lib/ResponseDefinitions.php
apps/files/openapi.json
apps/files/src/components/TemplateFiller.vue
lib/public/Files/Template/BeforeGetTemplatesEvent.php
lib/public/Files/Template/Field.php
lib/public/Files/Template/ITemplateManager.php

index f4770cb562354dc10f9983bc8766d6b9609d6d19..bdc4fd7f8a060b5a9160045b3da7364056708688 100644 (file)
@@ -21,6 +21,7 @@ use OCP\IRequest;
 /**
  * @psalm-import-type FilesTemplateFile from ResponseDefinitions
  * @psalm-import-type FilesTemplateFileCreator from ResponseDefinitions
+ * @psalm-import-type FilesTemplateField from ResponseDefinitions
  */
 class TemplateController extends OCSController {
        protected $templateManager;
@@ -51,7 +52,7 @@ class TemplateController extends OCSController {
         * @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
index 01b20a34cac797dbeb6b2525a5091e0f64ef91a2..50893af7b116e5b0d3b5535f1c26025e01340a11 100644 (file)
@@ -32,6 +32,12 @@ namespace OCA\Files;
  *     ratio: ?float,
  *     actionLabel: string,
  * }
+ *
+ * @psalm-type FilesTemplateField = array{
+ *     index: string,
+ *     content: string,
+ *     type: string,
+ * }
  */
 class ResponseDefinitions {
 }
index 6fff32e485452312915e195167395766f28edad1..e93c4d2807afa476b65478abcb93fde53d513224 100644 (file)
                                         "type": "string",
                                         "default": "user",
                                         "description": "Type of the template"
+                                    },
+                                    "templateFields": {
+                                        "type": "array",
+                                        "default": [],
+                                        "description": "Fields of the template",
+                                        "items": {
+                                            "$ref": "#/components/schemas/TemplateField"
+                                        }
                                     }
                                 }
                             }
index 082cf982d8298a45995a07df1d6e1b041951c560..926bcdd4dfd244c58608871bd93abb38ad07b681 100644 (file)
@@ -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">
index c4e23c17c7ce6f807d327e0ee2e20e8849a9da27..006163c5f7fcc3ace66c750ece3ab977f43298fa 100644 (file)
@@ -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
@@ -18,7 +20,7 @@ class BeforeGetTemplatesEvent extends Event {
 
        /**
         * @param array<Template> $templates
-        * 
+        *
         * @since 30.0.0
         */
        public function __construct(array $templates) {
@@ -29,7 +31,7 @@ class BeforeGetTemplatesEvent extends Event {
 
        /**
         * @return array<Template>
-        * 
+        *
         * @since 30.0.0
         */
        public function getTemplates(): array {
index 49c6a033e5ce4483ca5c4e3682a67ef1be646269..ce0ed3176d97c893970ff0c4267b2e31d0539504 100644 (file)
@@ -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
@@ -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 {
index 5adcc0ded2505cca23b2d0ff3afa8fe20a6273e8..94e0db935e7e4d8badd62faf63232e12451a14e8 100644 (file)
@@ -67,9 +67,11 @@ interface ITemplateManager {
        /**
         * @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;
 }