aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index eb98d5949..712404179 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -1122,17 +1122,26 @@ abstract class ElggEntity implements
}
/**
- * Returns tags for this entity using registered tag metadata names.
+ * Returns tags for this entity.
*
+ * @param array $tag_names Optionally restrict by tag metadata names.
* @return array
*/
- public function getTags() {
+ public function getTags($tag_names = NULL) {
global $CONFIG;
+ if ($tag_names && !is_array($tag_names)) {
+ $tag_names = array($tag_names);
+ }
+
$valid_tags = elgg_get_registered_tag_metadata_names();
$entity_tags = array();
foreach ($valid_tags as $tag_name) {
+ if (is_array($tag_names) && !in_array($tag_name, $tag_names)) {
+ continue;
+ }
+
if ($tags = $this->$tag_name) {
// if a single tag, metadata returns a string.
// if multiple tags, metadata returns an array.