From f06ae1840928b78a71acb7a5350b0815ed33d825 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 2 Nov 2008 00:24:23 +0000 Subject: [PATCH] API CHANGE Moved DataObject::get_by_url() to SiteTree::get_by_url() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65060 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObject.php | 11 ----------- core/model/SiteTree.php | 11 +++++++++++ tests/DataObjectTest.php | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 3edc44aa6..da684e705 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -2242,17 +2242,6 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP } } - /** - * Return the SiteTree object with the given URL segment. - * - * @param string $urlSegment The URL segment, eg 'home' - * - * @return SiteTree The object with the given URL segment - */ - public static function get_by_url($urlSegment) { - return DataObject::get_one("SiteTree", "URLSegment = '" . addslashes((string) $urlSegment) . "'"); - } - /** * Return the given element, searching by ID * diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index dd10a315a..47b533782 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -917,6 +917,17 @@ class SiteTree extends DataObject { } return $t; } + + /** + * Return the SiteTree object with the given URL segment. + * + * @param string $urlSegment The URL segment, eg 'home' + * + * @return SiteTree The object with the given URL segment + */ + public static function get_by_url($urlSegment) { + return DataObject::get_one("SiteTree", "URLSegment = '" . addslashes((string) $urlSegment) . "'"); + } /** * Replace a URL in html content with a new URL. diff --git a/tests/DataObjectTest.php b/tests/DataObjectTest.php index 4f1486dc1..e8b9264af 100644 --- a/tests/DataObjectTest.php +++ b/tests/DataObjectTest.php @@ -96,7 +96,7 @@ class DataObjectTest extends SapphireTest { $this->assertEquals('Home', $page->Title); // Test get_by_url() - $page = DataObject::get_by_url('home'); + $page = SiteTree::get_by_url('home'); $this->assertEquals($homepageID, $page->ID); // Test get_one() without caching