From a4d3de4ad774e93e4d003fcf2068330fe0ec5e97 Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Mon, 26 Aug 2024 13:41:33 -0400 Subject: [PATCH] feat: use field factory Signed-off-by: Elizabeth Danzberger --- lib/Service/TemplateFieldService.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Service/TemplateFieldService.php b/lib/Service/TemplateFieldService.php index a74e9d5f55..f0d6a03e38 100644 --- a/lib/Service/TemplateFieldService.php +++ b/lib/Service/TemplateFieldService.php @@ -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; @@ -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); + $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;