Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #343 from halkyon/object_static_remove_deprecation

BUGFIX Remove calls to deprecated Object static methods, update ConfigTest
  • Loading branch information...
commit 585417d1412e359d3144cbc55890a8217e0c879b 2 parents a687292 + ccb941e
@wilr wilr authored
View
6 admin/code/CMSBatchActionHandler.php
@@ -130,7 +130,7 @@ function handleAction($request) {
function handleApplicablePages($request) {
// Find the action handler
- $actions = Object::get_static($this->class, 'batch_actions');
+ $actions = Config::inst()->get($this->class, 'batch_actions', Config::FIRST_SET);
$actionClass = $actions[$request->param('BatchAction')];
$actionHandler = new $actionClass['class']();
@@ -152,7 +152,7 @@ function handleApplicablePages($request) {
function handleConfirmation($request) {
// Find the action handler
- $actions = Object::get_static($this->class, 'batch_actions');
+ $actions = Config::inst()->get($this->class, 'batch_actions', Config::FIRST_SET);
$actionClass = $actions[$request->param('BatchAction')];
$actionHandler = new $actionClass();
@@ -203,7 +203,7 @@ function batchActionList() {
* @return array See {@link register()} for the returned format.
*/
function batchActions() {
- $actions = Object::get_static($this->class, 'batch_actions');
+ $actions = Config::inst()->get($this->class, 'batch_actions', Config::FIRST_SET);
if($actions) foreach($actions as $action) {
if($action['recordClass'] != $this->recordClass) unset($action);
}
View
18 admin/code/CMSMenu.php
@@ -59,9 +59,9 @@ public static function add_controller($controllerClass) {
* Return a CMSMenuItem to add the given controller to the CMSMenu
*/
protected static function menuitem_for_controller($controllerClass) {
- $urlBase = Object::get_static($controllerClass, 'url_base');
- $urlSegment = Object::get_static($controllerClass, 'url_segment');
- $menuPriority = Object::get_static($controllerClass, 'menu_priority');
+ $urlBase = Config::inst()->get($controllerClass, 'url_base', Config::FIRST_SET);
+ $urlSegment = Config::inst()->get($controllerClass, 'url_segment', Config::FIRST_SET);
+ $menuPriority = Config::inst()->get($controllerClass, 'menu_priority', Config::FIRST_SET);
// Don't add menu items defined the old way
if($urlSegment === null && $controllerClass != "CMSMain") return;
@@ -81,12 +81,12 @@ protected static function menuitem_for_controller($controllerClass) {
* Add the appropriate Director rules for the given controller.
*/
protected static function add_director_rule_for_controller($controllerClass) {
- $urlBase = Object::get_static($controllerClass, 'url_base');
- $urlSegment = Object::get_static($controllerClass, 'url_segment');
- $urlRule = Object::get_static($controllerClass, 'url_rule');
- $urlPriority = Object::get_static($controllerClass, 'url_priority');
-
- if($urlSegment || $controllerClass == "CMSMain") {
+ $urlBase = Config::inst()->get($controllerClass, 'url_base', Config::FIRST_SET);
+ $urlSegment = Config::inst()->get($controllerClass, 'url_segment', Config::FIRST_SET);
+ $urlRule = Config::inst()->get($controllerClass, 'url_rule', Config::FIRST_SET);
+ $urlPriority = Config::inst()->get($controllerClass, 'url_priority', Config::FIRST_SET);
+
+ if($urlSegment || $controllerClass == 'CMSMain') {
$link = Controller::join_links($urlBase, $urlSegment) . '/';
// Make director rule
View
4 control/RequestHandler.php
@@ -138,8 +138,8 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
// We stop after RequestHandler; in other words, at ViewableData
while($handlerClass && $handlerClass != 'ViewableData') {
- $urlHandlers = Object::get_static($handlerClass, 'url_handlers');
-
+ $urlHandlers = Config::inst()->get($handlerClass, 'url_handlers', Config::FIRST_SET);
+
if($urlHandlers) foreach($urlHandlers as $rule => $action) {
if(isset($_REQUEST['debug_request'])) Debug::message("Testing '$rule' with '" . $request->remaining() . "' on $this->class");
if($params = $request->match($rule, true)) {
View
22 core/Object.php
@@ -333,9 +333,6 @@ public static function static_lookup($class, $name, $default = null) {
* If any extra values are discovered, they are then merged with the default PHP static values, or in some cases
* completely replace the default PHP static when you set $replace = true, and do not define extra data on any child
* classes
- *
- * Note that from SilverStripe 2.3.2, Object::get_static() can only be used to get public
- * static variables, not protected ones.
*
* @param string $class
* @param string $name the property name
@@ -343,7 +340,7 @@ public static function static_lookup($class, $name, $default = null) {
* @return mixed
*/
public static function get_static($class, $name, $uncached = false) {
- Deprecation::notice('3.1.0', 'combined_static is deprecated, replaced by Config#get');
+ Deprecation::notice('3.1.0', 'get_static is deprecated, replaced by Config#get');
return Config::inst()->get($class, $name, Config::FIRST_SET);
}
@@ -355,17 +352,12 @@ public static function get_static($class, $name, $uncached = false) {
* @param mixed $value
*/
public static function set_static($class, $name, $value) {
- Deprecation::notice('3.1.0', 'set_static is deprecated, replaced by Config#set');
+ Deprecation::notice('3.1.0', 'set_static is deprecated, replaced by Config#update');
Config::inst()->update($class, $name, $value);
}
/**
* Get an uninherited static variable - a variable that is explicity set in this class, and not in the parent class.
- *
- * Note that from SilverStripe 2.3.2, Object::uninherited_static() can only be used to get public
- * static variables, not protected ones.
- *
- * @todo Recursively filter out parent statics, currently only inspects the parent class
*
* @param string $class
* @param string $name
@@ -401,7 +393,7 @@ public static function combined_static($class, $name, $ceiling = false) {
* @param bool $replace replace existing static vars
*/
public static function addStaticVars($class, $properties, $replace = false) {
- Deprecation::notice('3.1.0', 'addStaticVars is deprecated, replaced by Config#set');
+ Deprecation::notice('3.1.0', 'addStaticVars is deprecated, replaced by Config#update');
foreach($properties as $prop => $value) self::add_static_var($class, $prop, $value, $replace);
}
@@ -422,7 +414,7 @@ public static function addStaticVars($class, $properties, $replace = false) {
* @param bool $replace completely replace existing static values
*/
public static function add_static_var($class, $name, $value, $replace = false) {
- Deprecation::notice('3.1.0', 'add_static_var is deprecated, replaced by Config#set');
+ Deprecation::notice('3.1.0', 'add_static_var is deprecated, replaced by Config#remove and Config#update');
if ($replace) Config::inst()->remove($class, $name);
Config::inst()->update($class, $name, $value);
@@ -783,21 +775,21 @@ protected function createMethod($method, $code) {
* @see Object::get_static()
*/
public function stat($name, $uncached = false) {
- return self::get_static(($this->class ? $this->class : get_class($this)), $name, $uncached);
+ return Config::inst()->get(($this->class ? $this->class : get_class($this)), $name, Config::FIRST_SET);
}
/**
* @see Object::set_static()
*/
public function set_stat($name, $value) {
- self::set_static(($this->class ? $this->class : get_class($this)), $name, $value);
+ Config::inst()->update(($this->class ? $this->class : get_class($this)), $name, $value);
}
/**
* @see Object::uninherited_static()
*/
public function uninherited($name) {
- return self::uninherited_static(($this->class ? $this->class : get_class($this)), $name);
+ return Config::inst()->get(($this->class ? $this->class : get_class($this)), $name, Config::UNINHERITED);
}
/**
View
2  dev/Deprecation.php
@@ -145,7 +145,7 @@ public static function notice($atVersion, $string = '') {
// Get the level to raise the notice as
$level = self::$notice_level;
- if (!$level) $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_NOTICE;
+ if (!$level) $level = E_USER_DEPRECATED;
// Then raise the notice
if(substr($string,-1) != '.') $string .= ".";
View
6 dev/SapphireTest.php
@@ -332,8 +332,8 @@ protected function idFromFixture($className, $identifier) {
$match = $fixture->idFromFixture($className, $identifier);
if($match) return $match;
}
-
- $fixtureFiles = Object::get_static(get_class($this), 'fixture_file');
+
+ $fixtureFiles = Config::inst()->get(get_class($this), 'fixture_file', Config::FIRST_SET);
user_error(sprintf(
"Couldn't find object '%s' (class: %s) in files %s",
$identifier,
@@ -381,7 +381,7 @@ protected function objFromFixture($className, $identifier) {
if($match) return $match;
}
- $fixtureFiles = Object::get_static(get_class($this), 'fixture_file');
+ $fixtureFiles = Config::inst()->get(get_class($this), 'fixture_file', Config::FIRST_SET);
user_error(sprintf(
"Couldn't find object '%s' (class: %s) in files %s",
$identifier,
View
25 dev/TestRunner.php
@@ -254,19 +254,20 @@ function module($request, $coverage = false) {
*/
function runTests($classList, $coverage = false) {
$startTime = microtime(true);
-
- // XDEBUG seem to cause problems with test execution :-(
+
+ // disable xdebug, as it messes up test execution
if(function_exists('xdebug_disable')) xdebug_disable();
-
- ini_set('max_execution_time', 0);
-
+
+ ini_set('max_execution_time', 0);
+
$this->setUp();
-
+
// Optionally skip certain tests
$skipTests = array();
if($this->request->getVar('SkipTests')) {
$skipTests = explode(',', $this->request->getVar('SkipTests'));
}
+
$classList = array_diff($classList, $skipTests);
// run tests before outputting anything to the client
@@ -281,16 +282,14 @@ class_exists($className);
// Remove the error handler so that PHPUnit can add its own
restore_error_handler();
-
self::$default_reporter->writeHeader("SilverStripe Test Runner");
- if (count($classList) > 1) {
+ if (count($classList) > 1) {
self::$default_reporter->writeInfo("All Tests", "Running test cases: ",implode(", ", $classList));
- } else
- if (count($classList) == 1) {
- self::$default_reporter->writeInfo($classList[0], "");
+ } elseif (count($classList) == 1) {
+ self::$default_reporter->writeInfo($classList[0], '');
} else {
- // border case: no tests are available.
- self::$default_reporter->writeInfo("", "");
+ // border case: no tests are available.
+ self::$default_reporter->writeInfo('', '');
}
// perform unit tests (use PhpUnitWrapper or derived versions)
View
3  model/DataObject.php
@@ -2229,10 +2229,9 @@ function can($perm, $member = null) {
}
}
- $this->set_uninherited('permissionCache', $permissionCache);
+ Config::inst()->update($this->class, 'permissionCache', $permissionCache);
}
-
if($permissionCache[$memberID][$perm]) {
return in_array($this->ID, $permissionCache[$memberID][$perm]);
}
View
2  model/Versioned.php
@@ -308,7 +308,7 @@ function augmentDatabase() {
else $table = $classTable;
if($fields = DataObject::database_fields($this->owner->class)) {
- $options = Object::get_static($this->owner->class, 'create_table_options');
+ $options = Config::inst()->get($this->owner->class, 'create_table_options', Config::FIRST_SET);
$indexes = $this->owner->databaseIndexes();
if ($suffix && ($ext = $this->owner->getExtensionInstance($allSuffixes[$suffix]))) {
if (!$ext->isVersionedTable($table)) continue;
View
86 tests/core/ConfigTest.php
@@ -17,8 +17,94 @@ class ConfigTest_DefinesFooDoesntExtendObject {
protected static $foo = 4;
}
+class ConfigStaticTest_First extends Config {
+ public static $first = array('test_1');
+ public static $second = array('test_1');
+ public static $third = 'test_1';
+}
+
+class ConfigStaticTest_Second extends ConfigStaticTest_First {
+ public static $first = array('test_2');
+}
+
+class ConfigStaticTest_Third extends ConfigStaticTest_Second {
+ public static $first = array('test_3');
+ public static $second = array('test_3');
+ public static $fourth = array('test_3');
+}
+
+class ConfigStaticTest_Fourth extends ConfigStaticTest_Third {
+ public static $fourth = array('test_4');
+}
+
+class ConfigStaticTest_Combined1 extends Config {
+ public static $first = array('test_1');
+ public static $second = array('test_1');
+}
+
+class ConfigStaticTest_Combined2 extends ConfigStaticTest_Combined1 {
+ public static $first = array('test_2');
+ public static $second = null;
+}
+
+class ConfigStaticTest_Combined3 extends ConfigStaticTest_Combined2 {
+ public static $first = array('test_3');
+ public static $second = array('test_3');
+}
+
class ConfigTest extends SapphireTest {
+ function testUpdateStatic() {
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_First', 'first', Config::FIRST_SET), array('test_1'));
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Second', 'first', Config::FIRST_SET), array('test_2'));
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Third', 'first', Config::FIRST_SET), array('test_3'));
+
+ Config::inst()->update('ConfigStaticTest_First', 'first', array('test_1_2'));
+ Config::inst()->update('ConfigStaticTest_Third', 'first', array('test_3_2'));
+ Config::inst()->update('ConfigStaticTest_Fourth', 'first', array('test_4'));
+
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_First', 'first', Config::FIRST_SET), array('test_1_2', 'test_1'));
+
+ Config::inst()->update('ConfigStaticTest_Fourth', 'second', array('test_4'));
+ Config::inst()->update('ConfigStaticTest_Third', 'second', array('test_3_2'));
+
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Fourth', 'second', Config::FIRST_SET), array('test_4'));
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Third', 'second', Config::FIRST_SET), array('test_3_2', 'test_3'));
+
+ Config::inst()->remove('ConfigStaticTest_Third', 'second');
+ Config::inst()->update('ConfigStaticTest_Third', 'second', array('test_3_2'));
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Third', 'second', Config::FIRST_SET), array('test_3_2'));
+ }
+
+ function testUninheritedStatic() {
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_First', 'third', Config::UNINHERITED), 'test_1');
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Fourth', 'third', Config::UNINHERITED), null);
+
+ Config::inst()->update('ConfigStaticTest_First', 'first', array('test_1b'));
+ Config::inst()->update('ConfigStaticTest_Second', 'first', array('test_2b'));
+
+ // Check that it can be applied to parent and subclasses, and queried directly
+ $this->assertContains('test_1b', Config::inst()->get('ConfigStaticTest_First', 'first', Config::UNINHERITED));
+ $this->assertContains('test_2b', Config::inst()->get('ConfigStaticTest_Second', 'first', Config::UNINHERITED));
+
+ // But it won't affect subclasses - this is *uninherited* static
+ $this->assertNotContains('test_2b', Config::inst()->get('ConfigStaticTest_Third', 'first', Config::UNINHERITED));
+ $this->assertNotContains('test_2b', Config::inst()->get('ConfigStaticTest_Fourth', 'first', Config::UNINHERITED));
+
+ // Subclasses that don't have the static explicitly defined should allow definition, also
+ // This also checks that set can be called after the first uninherited get()
+ // call (which can be buggy due to caching)
+ Config::inst()->update('ConfigStaticTest_Fourth', 'first', array('test_4b'));
+ $this->assertContains('test_4b', Config::inst()->get('ConfigStaticTest_Fourth', 'first', Config::UNINHERITED));
+ }
+
+ function testCombinedStatic() {
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Combined3', 'first'), array('test_3', 'test_2', 'test_1'));
+
+ // test that null values are ignored, but values on either side are still merged
+ $this->assertEquals(Config::inst()->get('ConfigStaticTest_Combined3', 'second'), array('test_3', 'test_1'));
+ }
+
function testMerges() {
$result = array('A' => 1, 'B' => 2, 'C' => 3);
Config::merge_array_low_into_high($result, array('C' => 4, 'D' => 5));
View
136 tests/core/ObjectStaticTest.php
@@ -1,136 +0,0 @@
-<?php
-/**
- * Tests various static getter and setter methods on {@link Object}
- *
- * @package framework
- * @subpackage tests
- */
-class ObjectStaticTest extends SapphireTest {
-
- /**
- * Tests {@link Object::get_static()}
- */
- public function testGetStatic() {
- $this->assertEquals(Object::get_static('ObjectStaticTest_First', 'first'), array('test_1'));
- $this->assertEquals(Object::get_static('ObjectStaticTest_Second', 'first'), array('test_2'));
- $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'first'), array('test_3'));
-
- Object::addStaticVars('ObjectStaticTest_First', array('first' => array('test_1_2')));
- Object::addStaticVars('ObjectStaticTest_Third', array('first' => array('test_3_2')));
- Object::addStaticVars('ObjectStaticTest_Fourth', array('first' => array('test_4')));
-
- $this->assertEquals(Object::get_static('ObjectStaticTest_First', 'first', true), array('test_1_2', 'test_1'));
- // @todo - This fails. Decide if we can ignore this particular behaviour (it seems weird and counter-intuitive anyway)
- // $this->assertEquals(Object::get_static('ObjectStaticTest_Second', 'first', true), array('test_1_2', 'test_2'));
- // $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'first', true), array('test_1_2', 'test_3_2', 'test_3'));
- }
-
- /**
- * Test {@link Object::addStaticVar()} correctly replaces static vars
- */
- public function testAddStaticReplace() {
- Object::addStaticVars('ObjectStaticTest_Fourth', array('second' => array('test_4')), true);
- Object::addStaticVars('ObjectStaticTest_Third', array('second' => array('test_3_2')));
-
- $this->assertEquals(Object::get_static('ObjectStaticTest_Fourth', 'second', true), array('test_4'));
- $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'second', true), array('test_3_2', 'test_3'));
-
- Object::addStaticVars('ObjectStaticTest_Third', array('second' => array('test_3_2')), true);
- $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'second', true), array('test_3_2'));
-
- Object::add_static_var('ObjectStaticTest_Third', 'fourth', array('test_3_2'));
- // @todo - This fails. Decide if we can ignore this particular behaviour (it seems weird and counter-intuitive anyway)
- // $this->assertEquals(Object::get_static('ObjectStaticTest_Fourth', 'fourth', true), array('test_3_2', 'test_4'));
-
- Object::add_static_var('ObjectStaticTest_Third', 'fourth', array('test_3_2'), true);
- // @todo - This fails. Decide if we can ignore this particular behaviour (it seems weird and counter-intuitive anyway)
- // $this->assertEquals(Object::get_static('ObjectStaticTest_Fourth', 'fourth', true), array('test_4', 'test_3_2'));
- }
-
- /**
- * Tests {@link Object::uninherited_static()}
- */
- public function testUninherited() {
- $this->assertEquals(Object::uninherited_static('ObjectStaticTest_First', 'third', true), 'test_1');
- $this->assertEquals(Object::uninherited_static('ObjectStaticTest_Fourth', 'third', true), null);
- }
-
- public function testCombinedStatic() {
- // test basic operation
- $this->assertEquals (
- array('test_3', 'test_2', 'test_1'), Object::combined_static('ObjectStaticTest_Combined3', 'first')
- );
-
- // test that null values are ignored, but values on either side are still merged
- $this->assertEquals (
- array('test_3', 'test_1'), Object::combined_static('ObjectStaticTest_Combined3', 'second')
- );
-
- // test the $ceiling param
- // @todo - This fails, as it's been removed. Do we need it?
- // $this->assertEquals (
- // array('test_3', 'test_2'), Object::combined_static('ObjectStaticTest_Combined3', 'first', 'ObjectStaticTest_Combined2')
- // );
- }
-
- /**
- * Checks that Object::add_static_var() also works for uninherited stats
- */
- public function testAddStaticVarWorksForUninheritedStatics() {
- Object::add_static_var('ObjectStaticTest_First', 'first', array('test_1b'));
- Object::add_static_var('ObjectStaticTest_Second', 'first', array('test_2b'));
-
- // Check that it can be applied to parent and subclasses, and queried directly
- $this->assertContains('test_1b', Object::uninherited_static('ObjectStaticTest_First', 'first'));
- $this->assertContains('test_2b', Object::uninherited_static('ObjectStaticTest_Second', 'first'));
-
- // But it won't affect subclasses - this is *uninherited* static
- $this->assertNotContains('test_2b', Object::uninherited_static('ObjectStaticTest_Third', 'first'));
- $this->assertNotContains('test_2b', Object::uninherited_static('ObjectStaticTest_Fourth', 'first'));
-
- // Subclasses that don't have the static explicitly defined should allow definition, also
- // This also checks that add_static_var can be called after the first uninherited_static()
- // call (which can be buggy due to caching)
- Object::add_static_var('ObjectStaticTest_Fourth', 'first', array('test_4b'));
- $this->assertContains('test_4b', Object::uninherited_static('ObjectStaticTest_Fourth', 'first'));
- }
-
-}
-
-/**#@+
- * @ignore
- */
-class ObjectStaticTest_First extends Object {
- public static $first = array('test_1');
- public static $second = array('test_1');
- public static $third = 'test_1';
-}
-
-class ObjectStaticTest_Second extends ObjectStaticTest_First {
- public static $first = array('test_2');
-}
-
-class ObjectStaticTest_Third extends ObjectStaticTest_Second {
- public static $first = array('test_3');
- public static $second = array('test_3');
- public static $fourth = array('test_3');
-}
-
-class ObjectStaticTest_Fourth extends ObjectStaticTest_Third {
- public static $fourth = array('test_4');
-}
-
-class ObjectStaticTest_Combined1 extends Object {
- public static $first = array('test_1');
- public static $second = array('test_1');
-}
-
-class ObjectStaticTest_Combined2 extends ObjectStaticTest_Combined1 {
- public static $first = array('test_2');
- public static $second = null;
-}
-
-class ObjectStaticTest_Combined3 extends ObjectStaticTest_Combined2 {
- public static $first = array('test_3');
- public static $second = array('test_3');
-}
View
2  tests/model/DataExtensionTest.php
@@ -100,7 +100,7 @@ function testAddExtensionLoadsStatics() {
* Test that DataObject::$api_access can be set to true via a extension
*/
function testApiAccessCanBeExtended() {
- $this->assertTrue(Object::get_static('DataExtensionTest_Member', 'api_access'));
+ $this->assertTrue(Config::inst()->get('DataExtensionTest_Member', 'api_access', Config::FIRST_SET));
}
function testPermissionExtension() {
View
2  tests/model/DataObjectTest.php
@@ -1021,9 +1021,11 @@ function testRelField() {
function testRelObject() {
$captain = $this->objFromFixture('DataObjectTest_Player', 'captain1');
+
// Test traversal of a single has_one
$this->assertInstanceOf("Varchar", $captain->relObject('FavouriteTeam.Title'));
$this->assertEquals("Team 1", $captain->relObject('FavouriteTeam.Title')->getValue());
+
// Test direct field access
$this->assertInstanceOf("Boolean", $captain->relObject('IsRetired'));
$this->assertEquals(1, $captain->relObject('IsRetired')->getValue());
View
4 view/SSViewer.php
@@ -338,7 +338,7 @@ protected function createCallableArray(&$extraArray, $interfaceToQuery, $variabl
$exposedVariables = call_user_func(array($implementer, $variableMethod));
foreach($exposedVariables as $varName => $details) {
- if (!is_array($details)) $details = array('method' => $details, 'casting' => Object::get_static('ViewableData', 'default_cast'));
+ if (!is_array($details)) $details = array('method' => $details, 'casting' => Config::inst()->get('ViewableData', 'default_cast', Config::FIRST_SET));
// If just a value (and not a key => value pair), use it for both key and value
if (is_numeric($varName)) $varName = $details['method'];
@@ -405,7 +405,7 @@ function getInjectedValue($property, $params, $cast = true) {
// Get the object to cast as
$casting = isset($source['casting']) ? $source['casting'] : null;
// If not provided, use default
- if (!$casting) $casting = Object::get_static('ViewableData', 'default_cast');
+ if (!$casting) $casting = Config::inst()->get('ViewableData', 'default_cast', Config::FIRST_SET);
$obj = new $casting($property);
$obj->setValue($res['value']);
View
6 view/ViewableData.php
@@ -243,7 +243,7 @@ public function castingHelper($field) {
return $fieldSpec;
}
- $specs = Object::combined_static(get_class($this), 'casting');
+ $specs = Config::inst()->get(get_class($this), 'casting');
if(isset($specs[$field])) return $specs[$field];
if($this->failover) return $this->failover->castingHelper($field);
@@ -275,7 +275,7 @@ public function escapeTypeForField($field) {
$class = self::$default_cast;
}
- return Object::get_static($class, 'escape_type');
+ return Config::inst()->get($class, 'escape_type', Config::FIRST_SET);
}
/**
@@ -389,7 +389,7 @@ public function obj($fieldName, $arguments = null, $forceReturnedObject = true,
}
if(!is_object($value) && $forceReturnedObject) {
- $default = Object::get_static('ViewableData', 'default_cast');
+ $default = Config::inst()->get('ViewableData', 'default_cast', Config::FIRST_SET);
$value = new $default($fieldName);
}
Please sign in to comment.
Something went wrong with that request. Please try again.