From e877cf0f55df9703345325c9182cabd1c22c22d1 Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 9 Jul 2008 15:28:25 +0000 Subject: Refs #81: Subtype can be returned on a non-saved entity. git-svn-id: https://code.elgg.org/elgg/trunk@1363 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 1 - engine/lib/entities.php | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index c2cc9cff8..722591ab4 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -276,7 +276,6 @@ if (!isset($entity_class)) return false; $subtype = $entity->getSubtype(); - if (empty($subtype)) { $subtype = $entity_type; } if (elgg_view_exists("{$entity_type}/{$subtype}",$viewtype)) { diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 1a0f78249..2121429ac 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -389,7 +389,11 @@ * * @return string The entity subtype */ - public function getSubtype() { return get_subtype_from_id($this->get('subtype')); } + public function getSubtype() { + if (!((int) $this->guid > 0)) return $this->get('subtype'); // If this object hasn't been saved, then return the subtype string. + + return get_subtype_from_id($this->get('subtype')); + } /** * Gets the UNIX epoch time that this entity was created -- cgit v1.2.3