From e1a797c36b4a9ebf90f08d1a7cf81cacbdb0a4f0 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 15 Jul 2008 14:25:33 +0000 Subject: You can now override entity URLs with the setURL($string) method. git-svn-id: https://code.elgg.org/elgg/trunk@1427 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'engine/lib/entities.php') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index ff997810c..720597a83 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -39,7 +39,12 @@ * Any field not appearing in this will be viewed as a */ protected $attributes; - + + /** + * If set, overrides the value of getURL() + */ + protected $url_override; + /** * Temporary cache for metadata, permitting meta data access before a guid has obtained. */ @@ -437,7 +442,21 @@ * * @return string The URL */ - public function getURL() { return get_entity_url($this->getGUID()); } + public function getURL() { + if (!empty($this->url_override)) return $this->url_override; + return get_entity_url($this->getGUID()); + } + + /** + * Overrides the URL returned by getURL + * + * @param string $url The new item URL + * @return string The URL + */ + public function setURL($url) { + $this->url_override = $url; + return $url; + } /** * Tests to see whether the object has been fully loaded. @@ -1450,7 +1469,7 @@ global $CONFIG; if ($entity = get_entity($entity_guid)) { - $url = ""; + $url = ""; if (isset($CONFIG->entity_url_handler[$entity->getType()][$entity->getSubType()])) { $function = $CONFIG->entity_url_handler[$entity->getType()][$entity->getSubType()]; -- cgit v1.2.3