aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggMenuBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes/ElggMenuBuilder.php')
-rw-r--r--engine/classes/ElggMenuBuilder.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php
index f51ec8c62..33abc0c6b 100644
--- a/engine/classes/ElggMenuBuilder.php
+++ b/engine/classes/ElggMenuBuilder.php
@@ -179,9 +179,12 @@ class ElggMenuBuilder {
case 'title':
$sort_callback = array('ElggMenuBuilder', 'compareByTitle');
break;
- case 'name';
+ case 'name':
$sort_callback = array('ElggMenuBuilder', 'compareByName');
break;
+ case 'weight':
+ $sort_callback = array('ElggMenuBuilder', 'compareByWeight');
+ break;
case 'order':
// use registration order
return;
@@ -244,4 +247,18 @@ class ElggMenuBuilder {
return strcmp($a, $b);
}
+
+ /**
+ * Compare two menu items by their weight
+ *
+ * @param ElggMenuItem $a
+ * @param ElggMenuItem $b
+ * @return bool
+ */
+ public static function compareByWeight($a, $b) {
+ $a = $a->getWeight();
+ $b = $b->getWeight();
+
+ return $a > $b;
+ }
}