summaryrefslogtreecommitdiff
path: root/app/Formatter/GroupAutoCompleteFormatter.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-05 20:31:27 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-05 20:31:27 -0500
commite9fedf3e5cd63aea4da7a71f6647ee427c62fa49 (patch)
treeabc2de5aebace4a2d7c94805552264dab6b10bc7 /app/Formatter/GroupAutoCompleteFormatter.php
parent346b8312e5ac877ce3192c2db3a26b500018bbb5 (diff)
Rewrite of the authentication and authorization system
Diffstat (limited to 'app/Formatter/GroupAutoCompleteFormatter.php')
-rw-r--r--app/Formatter/GroupAutoCompleteFormatter.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/app/Formatter/GroupAutoCompleteFormatter.php b/app/Formatter/GroupAutoCompleteFormatter.php
new file mode 100644
index 00000000..7023e367
--- /dev/null
+++ b/app/Formatter/GroupAutoCompleteFormatter.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace Kanboard\Formatter;
+
+/**
+ * Autocomplete formatter for groups
+ *
+ * @package formatter
+ * @author Frederic Guillot
+ */
+class GroupAutoCompleteFormatter implements FormatterInterface
+{
+ /**
+ * Groups found
+ *
+ * @access private
+ * @var array
+ */
+ private $groups;
+
+ /**
+ * Format groups for the ajax autocompletion
+ *
+ * @access public
+ * @param array $groups
+ * @return GroupAutoCompleteFormatter
+ */
+ public function setGroups(array $groups)
+ {
+ $this->groups = $groups;
+ return $this;
+ }
+
+ /**
+ * Format groups for the ajax autocompletion
+ *
+ * @access public
+ * @return array
+ */
+ public function format()
+ {
+ $result = array();
+
+ foreach ($this->groups as $group) {
+ $result[] = array(
+ 'id' => $group->getInternalId(),
+ 'external_id' => $group->getExternalId(),
+ 'value' => $group->getName(),
+ 'label' => $group->getName(),
+ );
+ }
+
+ return $result;
+ }
+}