mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Consistently returning boolean values in DataObject->hasDatabaseField()
MINOR Documentation in DataObject git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73885 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9eb57d064e
commit
d2d04d950a
@ -2,6 +2,12 @@
|
|||||||
/**
|
/**
|
||||||
* A single database record & abstract class for the data-access-model.
|
* A single database record & abstract class for the data-access-model.
|
||||||
*
|
*
|
||||||
|
* <h2>Extensions and Decorators</h2>
|
||||||
|
*
|
||||||
|
* See {@link Extension} and {@link DataObjectDecorator}.
|
||||||
|
*
|
||||||
|
* <h2>Permission Control</h2>
|
||||||
|
*
|
||||||
* Object-level access control by {@link Permission}. Permission codes are arbitrary
|
* Object-level access control by {@link Permission}. Permission codes are arbitrary
|
||||||
* strings which can be selected on a group-by-group basis.
|
* strings which can be selected on a group-by-group basis.
|
||||||
*
|
*
|
||||||
@ -53,6 +59,10 @@
|
|||||||
* If any public method on this class is prefixed with an underscore,
|
* If any public method on this class is prefixed with an underscore,
|
||||||
* the results are cached in memory through {@link cachedCall()}.
|
* the results are cached in memory through {@link cachedCall()}.
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @todo Add instance specific removeExtension() which undos loadExtraStatics()
|
||||||
|
* and defineMethods()
|
||||||
|
*
|
||||||
* @package sapphire
|
* @package sapphire
|
||||||
* @subpackage model
|
* @subpackage model
|
||||||
*/
|
*/
|
||||||
@ -1934,6 +1944,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function hasDatabaseField($field) {
|
public function hasDatabaseField($field) {
|
||||||
|
// Add base fields which are not defined in static $db
|
||||||
$fixedFields = array(
|
$fixedFields = array(
|
||||||
'ID' => 'Int',
|
'ID' => 'Int',
|
||||||
'ClassName' => 'Enum',
|
'ClassName' => 'Enum',
|
||||||
@ -1943,8 +1954,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
'Version' => $this->hasExtension('Versioned') ? 'Int' : false,
|
'Version' => $this->hasExtension('Versioned') ? 'Int' : false,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add base fields which are not defined in static $db
|
if(isset($fixedFields[$field])) return true;
|
||||||
if(isset($fixedFields[$field])) return (bool)$fixedFields[$field];
|
|
||||||
|
|
||||||
return array_key_exists($field, $this->inheritedDatabaseFields());
|
return array_key_exists($field, $this->inheritedDatabaseFields());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user