Skip to content

Commit

Permalink
feat(template): pass optional data to field depending on field type
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Aug 16, 2024
1 parent 45b55c0 commit 5c2d218
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/Service/TemplateFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,23 @@ public function extractFields(Node|int $file) {
continue;
}

$fields[] = [
new Field(
$index,
$attr["content"],
$fieldType,
$attr["alias"],
$attr["id"],
$attr["tag"]
)
];
$field = new Field($index, $fieldType);

Check failure on line 72 in lib/Service/TemplateFieldService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

TooFewArguments

lib/Service/TemplateFieldService.php:72:14: TooFewArguments: Too few arguments for OCP\Files\Template\Field::__construct - expecting type to be passed (see https://psalm.dev/025)

Check failure on line 72 in lib/Service/TemplateFieldService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InvalidArgument

lib/Service/TemplateFieldService.php:72:32: InvalidArgument: Argument 2 of OCP\Files\Template\Field::__construct expects string, but enum(OCP\Files\Template\FieldType::CheckBox)|enum(OCP\Files\Template\FieldType::Date)|enum(OCP\Files\Template\FieldType::DropDownList)|enum(OCP\Files\Template\FieldType::Picture)|enum(OCP\Files\Template\FieldType::RichText) provided (see https://psalm.dev/004)
$field->id = $attr["id"];

Check failure on line 73 in lib/Service/TemplateFieldService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InaccessibleProperty

lib/Service/TemplateFieldService.php:73:5: InaccessibleProperty: Cannot access private property OCP\Files\Template\Field::$id from context OCA\Richdocuments\Service\TemplateFieldService (see https://psalm.dev/054)
$field->tag = $attr["tag"];

Check failure on line 74 in lib/Service/TemplateFieldService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InaccessibleProperty

lib/Service/TemplateFieldService.php:74:5: InaccessibleProperty: Cannot access private property OCP\Files\Template\Field::$tag from context OCA\Richdocuments\Service\TemplateFieldService (see https://psalm.dev/054)
$field->alias = $attr["alias"];

Check failure on line 75 in lib/Service/TemplateFieldService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InaccessibleProperty

lib/Service/TemplateFieldService.php:75:5: InaccessibleProperty: Cannot access private property OCP\Files\Template\Field::$alias from context OCA\Richdocuments\Service\TemplateFieldService (see https://psalm.dev/054)

switch ($fieldType) {
case FieldType::RichText:
$field->content = $attr["content"];

Check failure on line 79 in lib/Service/TemplateFieldService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

InaccessibleProperty

lib/Service/TemplateFieldService.php:79:7: InaccessibleProperty: Cannot access private property OCP\Files\Template\Field::$content from context OCA\Richdocuments\Service\TemplateFieldService (see https://psalm.dev/054)
break;
case FieldType::CheckBox:
$field->checked = ($attr["Checked"] === "true");

Check failure on line 82 in lib/Service/TemplateFieldService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedPropertyAssignment

lib/Service/TemplateFieldService.php:82:7: UndefinedPropertyAssignment: Instance property OCP\Files\Template\Field::$checked is not defined (see https://psalm.dev/038)
break;
default:
break;
}

$fields[] = [$field];
}

return array_merge([], ...$fields);
Expand Down

0 comments on commit 5c2d218

Please sign in to comment.