MINOR Changed places of Object::extInstance() to Object::getExtensionInstance() and added a notice if extInstance is used in future

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100487 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-03-04 04:15:42 +00:00 committed by Sam Minnee
parent 5ff51cf936
commit d91fa6fdfd
4 changed files with 6 additions and 5 deletions

View File

@ -1006,6 +1006,7 @@ abstract class Object {
* @deprecated 2.4 Use getExtensionInstance
*/
public function extInstance($extension) {
user_error('Object::extInstance() is deprecated. Please use Object::getExtensionInstance() instead.', E_USER_NOTICE);
return $this->getExtensionInstance($extension);
}

View File

@ -237,7 +237,7 @@ class Versioned extends DataObjectDecorator {
if($fields = DataObject::database_fields($this->owner->class)) {
$indexes = $this->owner->databaseIndexes();
if ($suffix && ($ext = $this->owner->extInstance($allSuffixes[$suffix]))) {
if ($suffix && ($ext = $this->owner->getExtensionInstance($allSuffixes[$suffix]))) {
if (!$ext->isVersionedTable($table)) continue;
$ext->setOwner($this->owner);
$fields = $ext->fieldsInExtraTables($suffix);
@ -417,7 +417,7 @@ class Versioned extends DataObjectDecorator {
function extendWithSuffix($table) {
foreach (Versioned::$versionableExtensions as $versionableExtension => $suffixes) {
if ($this->owner->hasExtension($versionableExtension)) {
$ext = $this->owner->extInstance($versionableExtension);
$ext = $this->owner->getExtensionInstance($versionableExtension);
$ext->setOwner($this->owner);
$table = $ext->extendWithSuffix($table);
$ext->clearOwner();

View File

@ -423,7 +423,7 @@ class Group extends DataObject {
* Filters to only those groups that the current user can edit
*/
function AllChildrenIncludingDeleted() {
$extInstance = $this->extInstance('Hierarchy');
$extInstance = $this->getExtensionInstance('Hierarchy');
$extInstance->setOwner($this);
$children = $extInstance->AllChildrenIncludingDeleted();
$extInstance->clearOwner();

View File

@ -290,13 +290,13 @@ class ObjectTest extends SapphireTest {
}
/**
* Tests {@link Object::hasExtension() and Object::extInstance()}
* Tests {@link Object::hasExtension() and Object::getExtensionInstance()}
*/
public function testExtInstance() {
$obj = new ObjectTest_ExtensionTest2();
$this->assertTrue($obj->hasExtension('ObjectTest_Extension'));
$this->assertTrue($obj->extInstance('ObjectTest_Extension') instanceof ObjectTest_Extension);
$this->assertTrue($obj->getExtensionInstance('ObjectTest_Extension') instanceof ObjectTest_Extension);
}
public function testCacheToFile() {