From d91fa6fdfda83a9132ff45d17d0b1bb5abcd8bbc Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 4 Mar 2010 04:15:42 +0000 Subject: [PATCH] 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 --- core/Object.php | 1 + core/model/Versioned.php | 4 ++-- security/Group.php | 2 +- tests/ObjectTest.php | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/Object.php b/core/Object.php index ccac23b69..e914bed0d 100755 --- a/core/Object.php +++ b/core/Object.php @@ -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); } diff --git a/core/model/Versioned.php b/core/model/Versioned.php index e9ac88506..53dab3d55 100755 --- a/core/model/Versioned.php +++ b/core/model/Versioned.php @@ -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(); diff --git a/security/Group.php b/security/Group.php index 7a0e88b17..dd47e9152 100644 --- a/security/Group.php +++ b/security/Group.php @@ -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(); diff --git a/tests/ObjectTest.php b/tests/ObjectTest.php index 392050f61..b7927f586 100755 --- a/tests/ObjectTest.php +++ b/tests/ObjectTest.php @@ -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() {