Skip to content

Commit

Permalink
feat: use field factory
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Aug 26, 2024
1 parent a51bce3 commit a4d3de4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/Service/TemplateFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\Template\Field;
use OCP\Files\Template\FieldFactory;
use OCP\Files\Template\FieldType;
use OCP\Http\Client\IClientService;
use OCP\ICacheFactory;
Expand Down Expand Up @@ -94,17 +95,17 @@ public function extractFields(Node|int $file): array {
continue;
}

$field = new Field($index, $fieldType);
$field->id = $attr["id"];
$field->tag = $attr["tag"];
$field->alias = $attr["alias"];
$field = FieldFactory::createField($index, $fieldType);

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

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Service/TemplateFieldService.php:98:14: UndefinedClass: Class, interface or enum named OCP\Files\Template\FieldFactory does not exist (see https://psalm.dev/019)
$field->id = $attr['id'];
$field->tag = $attr['tag'];
$field->alias = $attr['alias'];

switch ($fieldType) {
case FieldType::RichText:
$field->content = $attr["content"];
$field->setValue($attr['content']);
break;
case FieldType::CheckBox:
$field->checked = ($attr["Checked"] === "true");
$field->setValue($attr['Checked'] === 'true');
break;
default:
break;
Expand Down

0 comments on commit a4d3de4

Please sign in to comment.