aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-10 22:03:58 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-10 22:03:58 +0000
commit8f0161a9d382b5610326576a6f572d0beb8c3e03 (patch)
treef235dd5844b588fc0e1e12752818cea80fbaf566 /engine/lib/entities.php
parent9fa4cfbd1235a21803931aa58e7a650ad398e5fb (diff)
downloadelgg-8f0161a9d382b5610326576a6f572d0beb8c3e03.tar.gz
elgg-8f0161a9d382b5610326576a6f572d0beb8c3e03.tar.bz2
Added elgg_instanceof().
git-svn-id: http://code.elgg.org/elgg/trunk@5353 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index af5b140d9..17bc0aa1e 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -3631,6 +3631,28 @@ function recursive_delete_permissions_check($hook, $entity_type, $returnvalue, $
}
/**
+ * Checks if $entity is an ElggEntity and optionally for type and subtype.
+ *
+ * @param $entity
+ * @param $type
+ * @param $subtype
+ * @return Bool
+ */
+function elgg_instanceof($entity, $type = NULL, $subtype = NULL) {
+ $return = ($entity instanceof ElggEntity);
+
+ if ($type) {
+ $return = $return && ($entity->getType() == $type);
+ }
+
+ if ($subtype) {
+ $return = $return && ($entity->getSubtype() == $subtype);
+ }
+
+ return $return;
+}
+
+/**
* Garbage collect stub and fragments from any broken delete/create calls
*
* @param unknown_type $hook