mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
d19dd96793
commit
f06ae18409
@ -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
|
||||
*
|
||||
|
@ -918,6 +918,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.
|
||||
* @param string $old The old URL
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user