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
This commit is contained in:
Ingo Schommer 2008-11-02 00:24:23 +00:00
parent d19dd96793
commit f06ae18409
3 changed files with 12 additions and 12 deletions

View File

@ -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
*

View File

@ -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.

View File

@ -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