summaryrefslogtreecommitdiff
path: root/plugins/Timetrackingeditor/Formatter
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Timetrackingeditor/Formatter')
-rw-r--r--plugins/Timetrackingeditor/Formatter/SubtaskAutoCompleteFormatter.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/Timetrackingeditor/Formatter/SubtaskAutoCompleteFormatter.php b/plugins/Timetrackingeditor/Formatter/SubtaskAutoCompleteFormatter.php
new file mode 100644
index 00000000..724a146e
--- /dev/null
+++ b/plugins/Timetrackingeditor/Formatter/SubtaskAutoCompleteFormatter.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Kanboard\Plugin\Timetrackingeditor\Formatter;
+
+use Kanboard\Core\Filter\FormatterInterface;
+use Kanboard\Model\ProjectModel;
+use Kanboard\Model\SubtaskModel;
+use Kanboard\Model\TaskModel;
+use Kanboard\Formatter\BaseFormatter;
+
+/**
+ * Subtask AutoComplete Formatter
+ *
+ * @package formatter
+ * @author Thomas Stinner
+ */
+class SubtaskAutoCompleteFormatter extends BaseFormatter implements FormatterInterface
+{
+ /**
+ * Apply formatter
+ *
+ * @access public
+ * @return array
+ */
+ public function format()
+ {
+ $subtasks = $this->query->columns(
+ SubtaskModel::TABLE.'.id',
+ SubtaskModel::TABLE.'.title'
+ )->asc(SubtaskModel::TABLE.'.id')->findAll();
+
+ foreach ($subtasks as &$subtask) {
+ $subtask['value'] = $subtask['title'];
+ $subtask['label'] = ' > #'.$subtask['id'].' '.$subtask['title'];
+ }
+
+ return $subtasks;
+ }
+}