Skip to content

Commit bd0b1a3

Browse files
committed
refactror(question): simplify code
1 parent 0c47776 commit bd0b1a3

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

inc/abstracttarget.class.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ protected function prepareTemplate($template, PluginFormcreatorFormAnswer $formA
217217
/**
218218
* Append fields data to input
219219
*
220-
* @param PluginFormcreatorFormanswer $formanswer the source formanswer
221220
* @param array $input data of the generated target
222-
* @return void
221+
* @param PluginFormcreatorFormanswer $formanswer the source formanswer
222+
* @return array
223223
*/
224-
protected function appendFieldsData(PluginFormcreatorFormanswer $formanswer, &$input): void {
224+
protected function appendFieldsData(array$input, PluginFormcreatorFormanswer $formanswer): array {
225225
global $DB;
226226

227227
//get all PluginFormcreatorAnswer
@@ -262,6 +262,8 @@ protected function appendFieldsData(PluginFormcreatorFormanswer $formanswer, &$i
262262
}
263263
$input['c_id'] = $blocks_field;
264264
}
265+
266+
return $input;
265267
}
266268

267269

inc/question.class.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ public function getRenderedHtml($domain, $canEdit = true, ?PluginFormcreatorForm
279279
return '';
280280
}
281281

282-
$html = '';
283-
284282
$field = $this->getSubField();
285283
if (!$field->isPrerequisites()) {
286284
return '';
@@ -292,7 +290,7 @@ public function getRenderedHtml($domain, $canEdit = true, ?PluginFormcreatorForm
292290
$x = $this->fields['col'];
293291
$width = $this->fields['width'];
294292
$hiddenAttribute = $isVisible ? '' : 'hidden=""';
295-
$html .= '<div'
293+
$html = '<div'
296294
. ' gs-x="' . $x . '"'
297295
. ' gs-w="' . $width . '"'
298296
. ' data-itemtype="' . self::class . '"'

inc/targetticket.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
893893

894894
$data = $this->prepareUploadedFiles($data, $formanswer);
895895

896-
$this->appendFieldsData($formanswer, $data);
896+
$data = $this->appendFieldsData($data, $formanswer);
897897

898898
// Cleanup actors array
899899
$data = $this->cleanActors($data);

0 commit comments

Comments
 (0)