aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/entities.php
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-14 10:52:56 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-10-14 10:52:56 +0000
commit79527ef4c43e97060d2412037adcdcb03220a4fa (patch)
tree7a1223f36e3a294fc914d640677911619bdbb5b7 /engine/lib/entities.php
parent873a388b27bdad5e281dca790a9990591c552c2d (diff)
downloadelgg-79527ef4c43e97060d2412037adcdcb03220a4fa.tar.gz
elgg-79527ef4c43e97060d2412037adcdcb03220a4fa.tar.bz2
Fixes #2403 - adds unregister_entity_type()
git-svn-id: http://code.elgg.org/elgg/trunk@7077 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/entities.php')
-rw-r--r--engine/lib/entities.php47
1 files changed, 44 insertions, 3 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 534b61e19..e788018e0 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -2114,8 +2114,8 @@ function register_entity_type($type, $subtype) {
global $CONFIG;
$type = strtolower($type);
- if (!in_array($type, array('object','site','group','user'))) {
- return false;
+ if (!in_array($type, array('object', 'site', 'group', 'user'))) {
+ return FALSE;
}
if (!isset($CONFIG->registered_entities)) {
@@ -2130,7 +2130,48 @@ function register_entity_type($type, $subtype) {
$CONFIG->registered_entities[$type][] = $subtype;
}
- return true;
+ return TRUE;
+}
+
+/**
+ * Unregisters an entity type and subtype as a public-facing entity.
+ *
+ * @warning With a blank subtype, it unregisters that entity type including
+ * all subtypes. This must be called after all subtypes have been registered.
+ *
+ * @param string $type The type of entity (object, site, user, group)
+ * @param string $subtype The subtype to register (may be blank)
+ * @return true|false Depending on success
+ * @see register_entity_type()
+ */
+function unregister_entity_type($type, $subtype) {
+ global $CONFIG;
+
+ $type = strtolower($type);
+ if (!in_array($type, array('object', 'site', 'group', 'user'))) {
+ return FALSE;
+ }
+
+ if (!isset($CONFIG->registered_entities)) {
+ return FALSE;
+ }
+
+ if (!isset($CONFIG->registered_entities[$type])) {
+ return FALSE;
+ }
+
+ if ($subtype) {
+ if (in_array($subtype, $CONFIG->registered_entities[$type])) {
+ $key = array_search($subtype, $CONFIG->registered_entities[$type]);
+ unset($CONFIG->registered_entities[$type][$key]);
+ } else {
+ return FALSE;
+ }
+ } else {
+ unset($CONFIG->registered_entities[$type]);
+ }
+
+ return TRUE;
}
/**